kr.co.hit.live.web.download
Class FileDispatcherWebAction

java.lang.Object
  extended by kr.co.hit.live.web.action.AbstractWebAction
      extended by kr.co.hit.live.web.download.FileDispatcherWebAction
All Implemented Interfaces:
WebAction
Direct Known Subclasses:
ScanFileDispatcherWebAction, UriFileDispatcherWebAction

public abstract class FileDispatcherWebAction
extends AbstractWebAction

FileDispatcher 기능을 WebAction으로 제공하는 기본 클래스이다.

Since:
4.0
Author:
김형도

Field Summary
static String DEFAULT_CONTENT_TYPE
           
static String DEFAULT_ENCODING
           
 
Fields inherited from class kr.co.hit.live.web.action.AbstractWebAction
context, logger
 
Constructor Summary
protected FileDispatcherWebAction()
           
 
Method Summary
protected abstract  void dispatch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          실제 파일을 데이터를 내려주는 메소드이다.
 WebActionForward execute(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          파일을 내려주는 WebAction 인터페이스의 execute() 메소드의 구현이다.
 String getContentType(String path)
          파일경로를 주면 확장자를 찾아서 contentsType을 반환한다.
protected  FileDispatcher getDispatcher()
           
 String getEncoding()
           
 String getErrorPage()
          파일을 찾을 수 없을 경우에 뿌려줄 에러 페이지의 경로를 반환한다.
protected  String getExtention(String path)
          path에 존재하는 확장자를 리턴한다.
protected  void initContentTypes()
          확장자별 contents type을 매핑한다.
protected  boolean isModifiedSince(javax.servlet.http.HttpServletRequest request, File file)
          HTTP Request 헤더에 "If-Modified-Since" 항목이 있을 경우 출력할 파일의 수정일시를 사용하여 변경여부를 반환한다.
 void setContentType(String contentString)
          확장자와 컨텐츠타입 매핑을 추가한다.
 void setEncoding(String encoding)
           
 void setErrorPage(String path)
          파일을 찾을 수 없을 경우에 뿌려줄 에러 페이지의 경로를 설정한다.
 void setNoCache(boolean b)
           
 void showConfiguration(javax.servlet.http.HttpServletResponse response)
          WebAction의 설정값을 출력하는 메소드이다.
protected  void writeHeader(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean lastModified)
          HTTP Header 쓰기.
 
Methods inherited from class kr.co.hit.live.web.action.AbstractWebAction
createForward, getServletContext, getWebApplicationContext, setForward, setPrefix, setSuffix, setWebApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ENCODING

public static final String DEFAULT_ENCODING
See Also:
Constant Field Values

DEFAULT_CONTENT_TYPE

public static final String DEFAULT_CONTENT_TYPE
See Also:
Constant Field Values
Constructor Detail

FileDispatcherWebAction

protected FileDispatcherWebAction()
Method Detail

dispatch

protected abstract void dispatch(javax.servlet.http.HttpServletRequest request,
                                 javax.servlet.http.HttpServletResponse response)
                          throws IOException
실제 파일을 데이터를 내려주는 메소드이다. 필요에 맞도록 구현한다.

Parameters:
request -
response -
Throws:
IOException

getDispatcher

protected FileDispatcher getDispatcher()

setEncoding

public void setEncoding(String encoding)

getEncoding

public String getEncoding()

setNoCache

public void setNoCache(boolean b)

setErrorPage

public void setErrorPage(String path)
파일을 찾을 수 없을 경우에 뿌려줄 에러 페이지의 경로를 설정한다.

Parameters:
path -

getErrorPage

public String getErrorPage()
파일을 찾을 수 없을 경우에 뿌려줄 에러 페이지의 경로를 반환한다.

Returns:

writeHeader

protected void writeHeader(javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response,
                           boolean lastModified)
HTTP Header 쓰기.

Parameters:
request -
response -

isModifiedSince

protected boolean isModifiedSince(javax.servlet.http.HttpServletRequest request,
                                  File file)
HTTP Request 헤더에 "If-Modified-Since" 항목이 있을 경우 출력할 파일의 수정일시를 사용하여 변경여부를 반환한다.

Parameters:
request -
file -
Returns:

execute

public WebActionForward execute(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response)
                         throws Exception
파일을 내려주는 WebAction 인터페이스의 execute() 메소드의 구현이다. 내부적으로 dispatch() 메소드를 호출한다.

Specified by:
execute in interface WebAction
Specified by:
execute in class AbstractWebAction
Returns:
Throws:
Exception

setContentType

public void setContentType(String contentString)
확장자와 컨텐츠타입 매핑을 추가한다. 예) ext:=text/xml

Parameters:
extension -
contentsType -

getContentType

public String getContentType(String path)
파일경로를 주면 확장자를 찾아서 contentsType을 반환한다.

Parameters:
fileExtension -
Returns:
contentsType에 해당되는 문자열, 없으면 null을 반환한다.

initContentTypes

protected void initContentTypes()
확장자별 contents type을 매핑한다.


getExtention

protected String getExtention(String path)
path에 존재하는 확장자를 리턴한다.

Parameters:
path -
Returns:

showConfiguration

public void showConfiguration(javax.servlet.http.HttpServletResponse response)
                       throws IOException
Description copied from interface: WebAction
WebAction의 설정값을 출력하는 메소드이다.

Specified by:
showConfiguration in interface WebAction
Overrides:
showConfiguration in class AbstractWebAction
Throws:
IOException


Copyright © 2014. All Rights Reserved.