import java.lang.reflect.InvocationTargetException; import org.apache.commons.beanutils.PropertyUtils; import org.apache.struts.webapp.example.*; act = request.getParameter("action"); if (act == null) { act = "Create"; } host = request.getParameter("host"); if (log.isDebugEnabled()) { log.debug("EditSubscriptionAction: Processing " + act + " action"); } // Is there a currently logged on user? user = (User) session.getAttribute(Constants.USER_KEY); if (user == null) { if (log.isTraceEnabled()) { log.trace(" User is not logged on in session " + session.getId()); } struts.forwardName="logon"; return; } // Identify the relevant subscription subscription = user.findSubscription(request.getParameter("host")); if ((subscription == null) && !act.equals("Create")) { if (log.isTraceEnabled()) { log.trace(" No subscription for user " + user.getUsername() + " and host " + host); } struts.forwardName = "failure"; return; } if (subscription != null) { session.setAttribute(Constants.SUBSCRIPTION_KEY, subscription); } form = struts.form; form.setAction(act); if (!act.equals("Create")) { if (log.isTraceEnabled()) { log.trace(" Populating form from " + subscription); } try { PropertyUtils.copyProperties(form, subscription); form.setAction(act); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t == null) t = e; log.error("SubscriptionForm.populate", t); throw new ServletException("SubscriptionForm.populate", t); } catch (Throwable t) { log.error("SubscriptionForm.populate", t); throw new ServletException("SubscriptionForm.populate", t); } } // Forward control to the edit subscription page if (log.isTraceEnabled()) { log.trace(" Forwarding to 'success' page"); } struts.forwardName = "success";