1 16 package com.blandware.atleap.webapp.action.testimonials; 17 18 import com.blandware.atleap.common.TestimonialModuleConstants; 19 import com.blandware.atleap.model.testimonials.Testimonial; 20 import com.blandware.atleap.service.testimonials.TestimonialManager; 21 import com.blandware.atleap.webapp.action.core.BaseAction; 22 import com.blandware.atleap.webapp.form.TestimonialForm; 23 import com.blandware.atleap.webapp.util.testimonials.TestimonialModuleWebConstants; 24 import org.apache.commons.validator.GenericValidator; 25 import org.apache.struts.action.ActionForm; 26 import org.apache.struts.action.ActionForward; 27 import org.apache.struts.action.ActionMapping; 28 29 import javax.servlet.http.HttpServletRequest ; 30 import javax.servlet.http.HttpServletResponse ; 31 32 50 public final class ShowTestimonialAction extends BaseAction { 51 60 public ActionForward execute(ActionMapping mapping, ActionForm form, 61 HttpServletRequest request, HttpServletResponse response) throws Exception { 62 TestimonialForm testimonialForm = (TestimonialForm) form; 63 Long testimonialId = null; 64 if ( !GenericValidator.isBlankOrNull(testimonialForm.getId()) ) { 65 testimonialId = Long.valueOf(testimonialForm.getId()); 66 } else if ( request.getSession().getAttribute(TestimonialModuleWebConstants.TESTIMONIAL_ID_KEY) != null ) { 67 testimonialId = (Long ) request.getSession().getAttribute(TestimonialModuleWebConstants.TESTIMONIAL_ID_KEY); 68 } else { 69 if ( log.isWarnEnabled() ) { 70 log.warn("Missing content page ID. Returning to list..."); 71 } 72 return mapping.findForward("listTestimonials"); 73 } 74 75 TestimonialManager testimonialManager = (TestimonialManager) getBean(TestimonialModuleConstants.TESTIMONIAL_MANAGER_BEAN); 76 Testimonial testimonial = testimonialManager.retrieveTestimonial(testimonialId); 77 if ( testimonial == null ) { 78 response.sendError(HttpServletResponse.SC_NOT_FOUND); 79 return null; 80 } 81 82 if ( !testimonial.getActive().booleanValue() ) { 83 response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE); 84 return null; 85 } 86 87 request.setAttribute("testimonial", testimonial); 88 return mapping.findForward("viewTestimonial"); 89 } 90 } | Popular Tags |