001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.captcha;
016    
017    import com.liferay.portal.kernel.captcha.CaptchaUtil;
018    import com.liferay.portal.kernel.log.Log;
019    import com.liferay.portal.kernel.log.LogFactoryUtil;
020    import com.liferay.portal.struts.ActionConstants;
021    import com.liferay.portal.struts.PortletAction;
022    
023    import javax.portlet.ActionRequest;
024    import javax.portlet.ActionResponse;
025    import javax.portlet.PortletConfig;
026    
027    import org.apache.struts.action.ActionForm;
028    import org.apache.struts.action.ActionMapping;
029    
030    /**
031     * @author Brian Wing Shun Chan
032     */
033    public class CaptchaPortletAction extends PortletAction {
034    
035            public void processAction(
036                            ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
037                            ActionRequest actionRequest, ActionResponse actionResponse)
038                    throws Exception {
039    
040                    try {
041                            CaptchaUtil.serveImage(actionRequest, actionResponse);
042    
043                            setForward(actionRequest, ActionConstants.COMMON_NULL);
044                    }
045                    catch (Exception e) {
046                            _log.error(e);
047                    }
048            }
049    
050            protected boolean isCheckMethodOnProcessAction() {
051                    return _CHECK_METHOD_ON_PROCESS_ACTION;
052            }
053    
054            private static final boolean _CHECK_METHOD_ON_PROCESS_ACTION = false;
055    
056            private static Log _log = LogFactoryUtil.getLog(CaptchaPortletAction.class);
057    
058    }