r68 - trunk/nuiton-struts2/src/main/java/org/nuiton/web/struts2/interceptor
Author: tchemit Date: 2011-05-10 23:36:26 +0200 (Tue, 10 May 2011) New Revision: 68 Url: http://nuiton.org/repositories/revision/nuiton-web/68 Log: remove unused interceptor Removed: trunk/nuiton-struts2/src/main/java/org/nuiton/web/struts2/interceptor/DownloadInterceptor.java Deleted: trunk/nuiton-struts2/src/main/java/org/nuiton/web/struts2/interceptor/DownloadInterceptor.java =================================================================== --- trunk/nuiton-struts2/src/main/java/org/nuiton/web/struts2/interceptor/DownloadInterceptor.java 2011-05-10 14:34:24 UTC (rev 67) +++ trunk/nuiton-struts2/src/main/java/org/nuiton/web/struts2/interceptor/DownloadInterceptor.java 2011-05-10 21:36:26 UTC (rev 68) @@ -1,109 +0,0 @@ -/* - * #%L - * Nuiton Web :: Nuiton Struts 2 - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2010 - 2011 CodeLutin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/lgpl-3.0.html>. - * #L% - */ - -package org.nuiton.web.struts2.interceptor; - -import com.opensymphony.xwork2.ActionInvocation; -import com.opensymphony.xwork2.interceptor.AbstractInterceptor; -import com.opensymphony.xwork2.util.reflection.ReflectionProvider; -import com.opensymphony.xwork2.util.reflection.ReflectionProviderFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.io.InputStream; -import java.lang.reflect.Method; - -/** - * A interceptor to download a stream. - * <p/> - * The main purpose of this one is to clean nicely the incoming stream. - * - * @author tchemit <chemit@codelutin.com> - * @since 1.1 - */ -public class DownloadInterceptor extends AbstractInterceptor { - - /** Logger. */ - private static final Log log = LogFactory.getLog(DownloadInterceptor.class); - - private static final long serialVersionUID = 1L; - - /** - * Name of the field containing the stream in the action. - * <p/> - * By default, use as in result of type stream the value - * {@code inputStream}. - */ - protected String inputName = "inputStream"; - - public void setInputName(String inputName) { - this.inputName = inputName; - } - - @Override - public void init() { - super.init(); - if (log.isInfoEnabled()) { - log.info("Init interceptor..."); - } - } - - @Override - public String intercept(ActionInvocation invocation) throws Exception { - - Object action = invocation.getAction(); - - ReflectionProvider reflectionProvider = - ReflectionProviderFactory.getInstance(); - - Method getMethod; - - try { - getMethod = reflectionProvider.getGetMethod(action.getClass(), inputName); - } catch (Exception e) { - throw new IllegalStateException("Could not find field accessor for property name " + inputName + " in action " + action.getClass()); - } - - if (!InputStream.class.isAssignableFrom(getMethod.getReturnType())) { - throw new IllegalStateException("field for property name " + inputName + " in action " + action.getClass() + " is not a InputStream, but " + getMethod.getReturnType().getName()); - } - - try { - // let's invoke action and rest of interceptors - String invoke = invocation.invoke(); - return invoke; - } finally { - - InputStream inputStream = (InputStream) getMethod.invoke(action); - - if (log.isDebugEnabled()) { - log.debug("Will close inputStream " + inputStream); - } - // do close the input stream... - inputStream.close(); - } - - } -}
participants (1)
-
tchemit@users.nuiton.org