Expression _rhsExp = null;
TypeInfo lType = null;
// try
// {
InternalClient internalClientObj = null;
// System.out.println("parameters List " + _paramList);
if (_paramList.size() == 0)
{
logger
.severe("number of parameters passed to a InvokePolicyAction should be 2 or more");
throw new SPLException(Messages.getString(
"SPL_NO_OF_ARGUMENTS_PASSED_ERROR_MSG", new Object[] {
"2 or more", "0" }));
}
else
{
internalClientObj = InternalClientFactory.getInternalClient();
_lhsExp = (Expression) _paramList.get(0);
lType = _lhsExp.getType();
if (lType.getType() != TypeConstants.stringType)
{
logger
.severe("first Expression should be a string describing the name of the policy to invoke");
throw new SPLException(
Messages
.getString("SPL_INVOKE_POLICY_ACTION_EXCEPTION1_MSG"));
}
String policyName = (String) _lhsExp.evaluate();
if (_paramList.size() > 1)
{
// get second parameter
_rhsExp = (Expression) _paramList.get(1);
Object rhsResult = _rhsExp.evaluate();
if ((rhsResult instanceof java.util.List))
{
List instanceInfoList = (List) rhsResult;
internalClientObj.invokePolicy(policyName,
instanceInfoList, true);
}
else
{
Map instanceInfoMap = new HashMap();
Expression tempExpr = null;
Object keyObj = null;
Object valueObj = null;
if (((_paramList.size() - 1) % 2) == 0)
{
for (int i = 1; i < _paramList.size(); i++)
{
tempExpr = (Expression) _paramList.get(i);
keyObj = tempExpr.evaluate();
if (++i < _paramList.size())
{
tempExpr = (Expression) _paramList.get(i);
valueObj = tempExpr.evaluate();
}
else
{
logger
.severe("instance names and instances passed are not same");
throw new SPLException(
"instance names and instances passed are not same");
}
instanceInfoMap.put(keyObj, valueObj);
}
internalClientObj.invokePolicy(policyName,
instanceInfoMap);
} else {
throw new SPLException(
"number of parameters passed is insufficient to invoke the policy");
}
}
} else {
internalClientObj.invokePolicy(policyName, null, true);
}
}
logger.exiting(sourceClass, Thread.currentThread().getName() + " "
+ "execute");
return true;