package com.dev.swms.server.action;

import java.util.Map;

import com.dev.energy.server.action.AbstractAction;
import com.dev.energy.server.service.security.RoleManager;
import com.dev.energy.server.web.security.UserHolder;

/**
 * @author  dev
 */
public class RolePermissionAction extends AbstractAction{
	protected final RoleManager roleManager;
	
	public RolePermissionAction(RoleManager manager) {
		roleManager = manager;
	}

	public void invokePermission(Map clientParams){
		Long roleId = (Long) clientParams.get("role.id");
		clientParams.remove("role.id");
		String refModel = UserHolder.getReferenceModel();
		if(logger.isDebugEnabled()) {
			logger.debug("invoke permission to role " + roleId + " with params[" + clientParams + "]");
		}
		roleManager.invokePermission(roleId,refModel,clientParams);
	}
}
