{
private static Logger logger = Logger.getLogger(LiteratureListDeleteHandler.class);
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException, CommunicationException, NamingException
{
String dataSource = Settings.getInstance().getSiteInfo(CVUtility.getHostName(super.getServlet().getServletContext())).getDataSource();
HttpSession session = request.getSession(true);
int individualId = ((UserObject)session.getAttribute("userobject")).getIndividualID();
ArrayList deleteLog = new ArrayList();
String rowId[] = request.getParameterValues("rowId");
MarketingFacadeHome marketingFacadeHome = (MarketingFacadeHome)CVUtility.getHomeObject("com.centraview.marketing.marketingfacade.MarketingFacadeHome","MarketingFacade");
try
{
MarketingFacade remote = (MarketingFacade)marketingFacadeHome.create();
remote.setDataSource(dataSource);
for (int i=0; i<rowId.length; i++)
{
if(rowId[i] != null && !rowId[i].equals(""))
{
int elementId = Integer.parseInt(rowId[i]);
try
{
remote.deleteLiterature(elementId, individualId);
} catch(AuthorizationFailedException ae) {
String errorMessage = ae.getExceptionDescription();
deleteLog.add(errorMessage);
}
}
}
} catch(CreateException e) {
logger.error("[execute] Exception thrown.", e);
throw new CommunicationException(e.getMessage());
}
if (!deleteLog.isEmpty())
{
ActionErrors allErrors = new ActionErrors();
allErrors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.freeForm", "You do not have permission to delete one or more of the records you selected."));
session.setAttribute("listErrorMessage", allErrors);
}
return new ActionForward(request.getParameter("currentPage"), true);
}