001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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            @Override
036            public void processAction(
037                            ActionMapping actionMapping, ActionForm actionForm,
038                            PortletConfig portletConfig, ActionRequest actionRequest,
039                            ActionResponse actionResponse)
040                    throws Exception {
041    
042                    try {
043                            CaptchaUtil.serveImage(actionRequest, actionResponse);
044    
045                            setForward(actionRequest, ActionConstants.COMMON_NULL);
046                    }
047                    catch (Exception e) {
048                            _log.error(e);
049                    }
050            }
051    
052            @Override
053            protected boolean isCheckMethodOnProcessAction() {
054                    return _CHECK_METHOD_ON_PROCESS_ACTION;
055            }
056    
057            private static final boolean _CHECK_METHOD_ON_PROCESS_ACTION = false;
058    
059            private static Log _log = LogFactoryUtil.getLog(CaptchaPortletAction.class);
060    
061    }