01: package ru.emdev.EmForge.wiki.beanwrapper;
02:
03: import java.io.IOException;
04: import java.io.InputStream;
05: import java.util.Collection;
06: import java.util.Date;
07: import java.util.List;
08: import java.util.Properties;
09:
10: import org.springframework.context.ApplicationContext;
11:
12: import ru.emdev.EmForge.wiki.JspWikiEngineBean;
13:
14: import com.ecyrd.jspwiki.NoRequiredPropertyException;
15: import com.ecyrd.jspwiki.QueryItem;
16: import com.ecyrd.jspwiki.WikiEngine;
17: import com.ecyrd.jspwiki.WikiPage;
18: import com.ecyrd.jspwiki.attachment.Attachment;
19: import com.ecyrd.jspwiki.providers.ProviderException;
20: import com.ecyrd.jspwiki.providers.WikiAttachmentProvider;
21:
22: /** Wrapper for WikiAttachmentProvider allowed to use Spring-Beans in JspWiki
23: *
24: */
25: public class AttachmentProviderWrapper implements
26: WikiAttachmentProvider {
27: protected static final String BEAN_NAME_PROPERTY = "jspwiki.spring.attachmentProvider";
28: protected WikiAttachmentProvider m_bean;
29:
30: public void initialize(WikiEngine arg0, Properties arg1)
31: throws NoRequiredPropertyException, IOException {
32: ApplicationContext appContext = (ApplicationContext) arg1
33: .get(JspWikiEngineBean.SPRING_CONTEXT_PROPERTY);
34:
35: m_bean = (WikiAttachmentProvider) appContext.getBean(arg1
36: .getProperty(BEAN_NAME_PROPERTY));
37:
38: m_bean.initialize(arg0, arg1);
39: }
40:
41: public void deleteAttachment(Attachment arg0)
42: throws ProviderException {
43: m_bean.deleteAttachment(arg0);
44:
45: }
46:
47: public void deleteVersion(Attachment arg0) throws ProviderException {
48: m_bean.deleteVersion(arg0);
49:
50: }
51:
52: public Collection findAttachments(QueryItem[] arg0) {
53: return m_bean.findAttachments(arg0);
54: }
55:
56: public InputStream getAttachmentData(Attachment arg0)
57: throws ProviderException, IOException {
58: return m_bean.getAttachmentData(arg0);
59: }
60:
61: public Attachment getAttachmentInfo(WikiPage arg0, String arg1,
62: int arg2) throws ProviderException {
63: return m_bean.getAttachmentInfo(arg0, arg1, arg2);
64: }
65:
66: public List getVersionHistory(Attachment arg0) {
67: return m_bean.getVersionHistory(arg0);
68: }
69:
70: public List listAllChanged(Date arg0) throws ProviderException {
71: return m_bean.listAllChanged(arg0);
72: }
73:
74: public Collection listAttachments(WikiPage arg0)
75: throws ProviderException {
76: return m_bean.listAttachments(arg0);
77: }
78:
79: public void moveAttachmentsForPage(String arg0, String arg1)
80: throws ProviderException {
81: m_bean.moveAttachmentsForPage(arg0, arg1);
82: }
83:
84: public void putAttachmentData(Attachment arg0, InputStream arg1)
85: throws ProviderException, IOException {
86: m_bean.putAttachmentData(arg0, arg1);
87:
88: }
89:
90: public String getProviderInfo() {
91: return m_bean.getProviderInfo();
92: }
93: }
|