refactoring which pattern would you recommend
I have the following piece of code that I am tring to refactor
private String handleAction(String action, HttpServletRequest request,
XMLDelegate xmlDelegate)throws RemoteException{
if (action.equals("getHoldings")){
String portfolios = request.getParameter("portfolios");
String secTypes = request.getParameter("secTypes");
System.out.println("portfolios=" + portfolios);
System.out.println("secTypes=" + secTypes);
return (xmlDelegate.getHoldingsXML(portfolios, secTypes));
}elseif (action.equals("isAuthorized")){
UserPrivilegesAO upao =new UserPrivilegesAO(request
.getParameter(Fields.userId));
String userId = request.getParameter(Fields.userId);
String pass = request.getParameter(Fields.passwd);
System.out.println("userId=" + userId);
if (upao.authenticated(pass))
return ("YES");
else
return ("NO");
}elseif (action.equals("getPortfolios")){
return (xmlDelegate.getPortfoliosXML());
}elseif (action.equals("getSecTypes")){
return (xmlDelegate.getSecTypesXML());
}elseif (action.equals("allPortByMVRequest")){
return (xmlDelegate.getAllPortByMVXML());
}elseif (action.equals("portBreakDownBySecTypeRequest")){
String portfolioId = request.getParameter("portfolioId");
return (xmlDelegate.getPortBreakDownBySecTypeXML(portfolioId));
}elseif (action.equals("portSecTypeBreakDownBySecSubTypeRequest")){
String portfolioId = request.getParameter("portfolioId");
String secType = request.getParameter("secType");
return (xmlDelegate.getPortSecTypeBreakDownBySecSubTypeXML(
portfolioId, secType));
}elseif (action.equals("getNaicShiftsForAport")){
String portfolioId = request.getParameter("portfolioId");
String direction = request.getParameter("direction");
System.out.println("direction=" + direction);
System.out.println("portfolioId=" + portfolioId);
return (xmlDelegate
.getNaicShiftsForAportXML(portfolioId, direction));
}elseif (action.equals("getNaicDetail")){
String portfolioId = request.getParameter("portfolioId");
String secType = request.getParameter("secType");
String asof = request.getParameter("asof");
String direction = request.getParameter("direction");
System.out.println("portfolioId=" + portfolioId);
System.out.println("secType=" + secType);
System.out.println("asof=" + asof);
System.out.println("direction=" + direction);
return (xmlDelegate.getNaicDetailXML(portfolioId, secType, asof,
direction));
}elseif (action.equals("getPortsHasNaicShifted")){
return (xmlDelegate.getPortsHasNaicShiftedXML());
}elseif (action.equals("portSecSubTypeBreakDownByCusipRequest")){
String portfolioId = request.getParameter("portfolioId");
String secType = request.getParameter("secType");
String secSubType = request.getParameter("secSubType");
return (xmlDelegate.getPortSecSubTypeBreakDownByCusipXML(
portfolioId, secType, secSubType));
}
returnnull;
}
As you might see there are a lot of if else statements. I want to replace it with a pattern, which patter would you recommend. I was thinking of factory but there is not enough business logic to mandate use of that, and there would be a proliferation of newar empty classes if I try that. but at the same time all these if else statements look extremely ugly and would not be very extensible or maintainable. So any advose in this refard would be great!!!

