Source Code Cross Referenced for AttachmentInfoController.java in  » Project-Management » EmForce » ru » emdev » EmForge » wiki » web » bean » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Project Management » EmForce » ru.emdev.EmForge.wiki.web.bean 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package ru.emdev.EmForge.wiki.web.bean;
002:
003:        import java.io.FileInputStream;
004:        import java.io.IOException;
005:        import java.io.InputStream;
006:
007:        import javax.faces.component.UIParameter;
008:
009:        import org.apache.commons.io.IOUtils;
010:        import org.apache.commons.logging.Log;
011:        import org.apache.commons.logging.LogFactory;
012:        import org.emforge.EmForgeException;
013:        import org.emforge.xfer.AttachmentHistoryTO;
014:        import org.emforge.xfer.AttachmentTO;
015:        import org.richfaces.event.UploadEvent;
016:        import org.richfaces.model.UploadItem;
017:        import org.springframework.beans.factory.InitializingBean;
018:
019:        import ru.emdev.EmForge.web.bean.MainMenuController.MainMenuItem;
020:
021:        public class AttachmentInfoController extends BaseWikiControllerImpl
022:                implements  InitializingBean {
023:            protected final Log logger = LogFactory.getLog(getClass());
024:
025:            private String m_fileName;
026:
027:            @Override
028:            protected void init() {
029:                m_pageName = getPageParam();
030:                m_fileName = getParam("attachment");
031:            }
032:
033:            @Override
034:            public MainMenuItem getSelectionItemOnMainMenu() {
035:                return null;
036:            }
037:
038:            @Override
039:            public String getTitleImpl() {
040:                return m_fileName;
041:            }
042:
043:            @Override
044:            public Crumb getTrailCrumbInfo() {
045:                return new Crumb(m_fileName, "attachInfo/" + m_pageName + "/"
046:                        + m_fileName);
047:            }
048:
049:            public void setAttachmentName(String i_name) {
050:                m_fileName = i_name;
051:            }
052:
053:            public String getAttachmentName() {
054:                return m_fileName;
055:            }
056:
057:            public String getViewUrl() {
058:                return m_wikiEngine.getViewURL(m_pageName);
059:            }
060:
061:            public String getViewAttachUrl() {
062:                return "attach/" + m_pageName + "/" + m_fileName;
063:            }
064:
065:            public AttachmentTO getAttachment() {
066:                try {
067:                    return m_attachmentService.getAttachment(m_pageName,
068:                            m_fileName);
069:                } catch (Exception ex) {
070:                    logger.error("Cannot get attachment", ex);
071:                    return null;
072:                }
073:            }
074:
075:            public String getFullAttachName() {
076:                return m_pageName + "/" + m_fileName;
077:            }
078:
079:            public String deleteAttachment() {
080:                AttachmentTO att = getAttachment();
081:                String pageName = att.getParentName();
082:
083:                try {
084:                    m_attachmentService.deleteAttachment(att);
085:                    redirect(m_wikiEngine.getViewURL(m_pageName));
086:                } catch (EmForgeException e) {
087:                    logger.error("Cannot delete attachment", e);
088:                    return null;
089:                }
090:
091:                redirect("wiki/" + pageName);
092:                return null;
093:            }
094:
095:            @SuppressWarnings("unchecked")
096:            public AttachmentHistoryTO[] getRevisionList() {
097:                try {
098:                    AttachmentTO att = new AttachmentTO();
099:                    att.setParentName(m_pageName);
100:                    att.setFileName(m_fileName);
101:                    return m_attachmentService.getAttachmentHistory(att);
102:                } catch (EmForgeException e) {
103:                    logger.error("Cannot get attachment version history", e);
104:                }
105:                return new AttachmentHistoryTO[0];
106:            }
107:
108:            /**
109:             * @return <code>True</code> if the current user is a writer, otherwise
110:             *         <code>False</code>
111:             */
112:            public boolean isCanDeleteAttachment() {
113:                return m_attachmentService.canDeleteAttachment(getAttachment());
114:            }
115:
116:            public void upload(UploadEvent event) throws IOException {
117:                try {
118:                    UploadItem item = event.getUploadItem();
119:
120:                    // get page name
121:                    for (Object uiObject : event.getComponent().getChildren()) {
122:                        if (uiObject instanceof  UIParameter) {
123:                            final UIParameter param = (UIParameter) uiObject;
124:                            if (param.getName().equals("page")) {
125:                                m_pageName = param.getValue().toString();
126:                            } else if (param.getName().equals("attachment")) {
127:                                m_fileName = param.getValue().toString();
128:                            }
129:                        }
130:                    }
131:
132:                    InputStream is = new FileInputStream(item.getFile());
133:                    byte[] content = IOUtils.toByteArray(is);
134:                    m_attachmentService.addAttachment(m_pageName, m_fileName,
135:                            content, null);
136:                } catch (Exception pex) {
137:                    logger.error("Cannot upload file", pex);
138:                }
139:            }
140:
141:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.