package com.orionplatform.user_management.account.tasks;

import java.util.Map;
import com.orionplatform.core.abstraction.Orion;
import com.orionplatform.core.exception.Assert;
import com.orionplatform.data.data_access.user.OrionUsersDAO;
import com.orionplatform.user_management.reset_password.CannotEnableUserAccountException;

public class EnableUserAccountTask extends Orion
{
    public static synchronized void run(Map<String, String[]> parameterMap) throws CannotEnableUserAccountException
    {
        Assert.notEmpty(parameterMap, "The parameterMap input cannot be null/empty.");
        String userID = parameterMap.get("input_user_ID_whose_account_to_enable")[0].trim();
        int numberOFRowsAffected = OrionUsersDAO.enableUserAccountByUserID(userID);
        
        if(numberOFRowsAffected == 0)
        {
            throw new CannotEnableUserAccountException("Cannot enable account of userID '{}'", userID);
        }
    }
}