// -------------------------- OTHER METHODS --------------------------
  public static Return<Boolean> changePassword(final HumanId humanId, final Password newPass) {

    Return<Boolean> returnVal;
    if (humanId.validate() != 0) {
      throw new ConstraintsViolatedException(humanId.getViolations());
    } else if (newPass.validate() != 0) {
      throw new ConstraintsViolatedException(newPass.getViolations());
    } else {
      returnVal = DB.getHumanCRUDHumanLocal(true).doUHumanPassword(humanId, newPass);
      if (returnVal.returnStatus() == 0 && returnVal.returnValue()) {
        Loggers.USER.info("Password changed for user " + humanId.getObj());
      }
    }
    return returnVal;
  }
  public static Return<Boolean> changePassword(
      final HttpSession httpSession,
      final HumanId humanId,
      final Password currentPass,
      final Password newPass) {

    Return<Boolean> returnVal;
    if (humanId.validate() != 0) {
      throw new ConstraintsViolatedException(humanId.getViolations());
    } else if (currentPass.validate() != 0) {
      throw new ConstraintsViolatedException(currentPass.getViolations());
    } else if (newPass.validate() != 0) {
      throw new ConstraintsViolatedException(newPass.getViolations());
    } else {
      returnVal = DB.getHumanCRUDHumanLocal(true).doUHumanPassword(humanId, currentPass, newPass);
      if (returnVal.returnStatus() == 0 && returnVal.returnValue()) {
        Loggers.USER.info("Password changed for user " + humanId.getObj());
        {
          Loggers.USER.info(
              "Attempting to invalidating session due to password change for user "
                  + humanId.getObj());
          if (httpSession != null) {
            try {
              httpSession.invalidate();
              Loggers.USER.info(
                  "Successfully to invalidated session due to password change for user "
                      + humanId.getObj());
            } catch (final Exception e) {
              Loggers.USER.info(
                  "FAILED to invalidated session due to password change for user "
                      + humanId.getObj());
              Loggers.EXCEPTION.error("", e);
            }
          }
        }
      }
    }
    return returnVal;
  }
  @Override
  public Return<File> run(
      File file,
      final Map parameterMap,
      final String userFileExtension,
      final HttpSession session) {
    final SmartLogger sl =
        SmartLogger.start(Loggers.LEVEL.SERVER_STATUS, "Uploading Album Photo", 60000, null, true);
    Return<File> r;
    /** Renaming the file to contain extension for image manipulation flexibility */
    try {
      File newFile = new File(file.getCanonicalPath() + "." + userFileExtension);
      final boolean rename = file.renameTo(newFile);

      if (!rename) {
        sl.complete("Rename Error!");
        return new ReturnImpl<File>(new RuntimeException("Rename Error"), "Rename Error!", true);
      }

      final SessionBoundBadRefWrapper<HumanUserLocal> s =
          (SessionBoundBadRefWrapper<HumanUserLocal>) session.getAttribute(ServletLogin.HumanUser);

      if (!s.isAlive()) {
        sl.complete("No Login!");
        r = new ReturnImpl<File>(ExceptionCache.NO_LOGIN, "Please login!", true);
      } else {
        final HumanId humanId = new HumanId(s.getBoundInstance().getHumanUserId()).getSelfAsValid();

        try {
          try {

            // Uploading Original
            final String cdnFileName = newFile.getName();
            sl.appendToLogMSG(UPLOADING_ORIGINAL_IMAGE);
            final boolean uploadedOriginal =
                client.storeObjectAs(
                    CONTAINER,
                    newFile,
                    FilesConstants.getMimetype(userFileExtension),
                    ORIGINAL + cdnFileName);

            BufferedImage bi = null;

            // Uploading Standard Size
            sl.appendToLogMSG(LOADING_IMAGE_AS_BUFFERED_IMAGE);
            bi = loadImage(newFile);

            sl.appendToLogMSG(SCALING_IMAGE);
            bi = scaleImage(bi, 600); // Reducing size of image to standard view

            sl.appendToLogMSG(SAVING_SCALED_IMAGE);
            saveImage(bi, newFile);

            final String cdnfileName = newFile.getName();
            sl.appendToLogMSG(UPLOADING_STANDARD_IMAGE);
            final boolean uploadedStandard =
                client.storeObjectAs(
                    CONTAINER, newFile, FilesConstants.getMimetype(userFileExtension), cdnfileName);

            // Uploading Thumb
            sl.appendToLogMSG(LOADING_IMAGE_AS_BUFFERED_IMAGE);
            bi = loadImage(newFile);

            sl.appendToLogMSG(SCALING_IMAGE);
            bi =
                scaleImage(
                    bi,
                    190); // Reducing size of image to blueprintcss span-5 just to save bandwidth
            // for the user.

            sl.appendToLogMSG(SAVING_SCALED_IMAGE);
            saveImage(bi, newFile);

            final String cdnThumbFileName = THUMBNAIL + newFile.getName();
            sl.appendToLogMSG(UPLOADING_IMAGE_THUMB);
            final boolean uploadedThumb =
                client.storeObjectAs(
                    CONTAINER,
                    newFile,
                    FilesConstants.getMimetype(userFileExtension),
                    cdnThumbFileName);

            if (uploadedStandard && uploadedThumb && uploadedOriginal) {
              final boolean deleted = newFile.delete();
              if (deleted) {
                final Return<Album> dbr =
                    DB.getHumanCrudPrivateEventLocal(true)
                        .uPrivateEventAddEntryToAlbum(
                            humanId,
                            Long.parseLong((String) parameterMap.get(ALBUM_PIVATE_EVENT_ID)),
                            new Obj<String>(cdnFileName).getSelfAsValid());
                if (dbr.returnStatus() == 0) {
                  sl.complete(Loggers.DONE);
                  r = new ReturnImpl<File>(newFile, ALBUM_PHOTO_UPLOAD_SUCCESSFUL);
                } else {
                  r =
                      new ReturnImpl<File>(
                          new DBOperationException(dbr.returnError()),
                          ALBUM_PHOTO_UPLOAD_FAILED_DUE_TO_I_O_ISSUES,
                          true);
                }
              } else {
                r =
                    new ReturnImpl<File>(
                        ExceptionCache.FILE_DELETE_FAILED,
                        ALBUM_PHOTO_UPLOAD_FAILED_DUE_TO_CACHING_ISSUES,
                        true);
              }
            } else {
              r =
                  new ReturnImpl<File>(
                      ExceptionCache.CDN_FILE_UPLOAD_FAILED,
                      ALBUM_PHOTO_UPLOAD_FAILED_DUE_TO_I_O_ISSUES,
                      true);
            }
          } catch (final IOException e) {
            r = new ReturnImpl<File>(e, ALBUM_PHOTO_UPLOAD_FAILED_DUE_TO_I_O_ISSUES, true);
          }
        } catch (
            final RuntimeException e) { // This is for the deleteObject's returnBadly from DB return
          r = new ReturnImpl<File>(e, ALBUM_PHOTO_UPLOAD_FAILED, true);
        } catch (final Exception e) {
          r =
              new ReturnImpl<File>(
                  e, ALBUM_PHOTO_UPLOAD_FAILED_DUE_TO_IMAGE_MANIPULATION_ISSUES, true);
        }
      }
    } catch (final IOException e) {
      r = new ReturnImpl<File>(e, ALBUM_PHOTO_UPLOAD_FAILED_DUE_TO_RENAMING_ISSUES, true);
    }
    return r;
  }