Source Code Cross Referenced for RecycleBin.java in  » J2EE » Enhydra-Demos » org » enhydra » dm » presentation » 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 » J2EE » Enhydra Demos » org.enhydra.dm.presentation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.enhydra.dm.presentation;
002:
003:        import java.text.SimpleDateFormat;
004:        import java.util.Date;
005:
006:        import org.enhydra.dm.EnhydraDM;
007:        import org.enhydra.dm.api.Document;
008:        import org.enhydra.dm.api.exceptions.BaseException;
009:        import org.enhydra.dm.business.exceptions.ActionNotAllowedException;
010:        import org.enhydra.dm.util.EnhydraDMConstants;
011:        import org.w3c.dom.Node;
012:        import org.w3c.dom.html.HTMLAnchorElement;
013:
014:        import com.lutris.appserver.server.httpPresentation.ClientPageRedirectException;
015:        import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
016:        import com.lutris.logging.Logger;
017:
018:        public class RecycleBin extends Base {
019:
020:            RecycleBinHTML page;
021:
022:            /*
023:             * There is the only function needed in order to be a presentation object.
024:             */
025:            public void run(HttpPresentationComms comms) throws Exception {
026:
027:                page = (RecycleBinHTML) comms.xmlcFactory
028:                        .create(RecycleBinHTML.class);
029:
030:                comms.request.getHttpServletRequest().setCharacterEncoding(
031:                        EnhydraDMConstants.ENCODING);
032:
033:                String documentid = comms.request
034:                        .getParameter(EnhydraDMConstants.DOCUMENT_ID);
035:                String action = comms.request
036:                        .getParameter(EnhydraDMConstants.ACTION);
037:                String mode = comms.request
038:                        .getParameter(EnhydraDMConstants.MODE);
039:
040:                boolean isTemplate = true;
041:                if (!EnhydraDMConstants.MODE_TEMPLATE.equals(mode)) {
042:                    mode = EnhydraDMConstants.MODE_DOCUMENT;
043:                    isTemplate = false;
044:                }
045:
046:                boolean doCommit = true;
047:                try {
048:                    initTransaction();
049:                    String user = getUser(comms);
050:                    documentManager = ((EnhydraDM) comms.application)
051:                            .getDocumentManager();
052:
053:                    if (null == user) {
054:                        throw new ActionNotAllowedException(
055:                                "User not registred;");
056:
057:                    }
058:                    if (null != action) {
059:                        if (EnhydraDMConstants.ACTION_RESTORE.equals(action)) {
060:                            restoreDocument(comms, documentid, user);
061:                        }
062:                        throw new ClientPageRedirectException(
063:                                EnhydraDMConstants.NAVIG_RECYCLEBIN + "?"
064:                                        + EnhydraDMConstants.MODE + "=" + mode);
065:                    }
066:
067:                    page.setTextUser("User: " + user);
068:
069:                    fillFilesetTable(comms, user, isTemplate);
070:
071:                    comms.response.writeDOM(page);
072:                } catch (BaseException ex) {
073:                    doCommit = false;
074:                    if (null != comms.application.getLogChannel()) {
075:                        comms.application.getLogChannel().write(
076:                                Logger.ERROR,
077:                                "Action :" + action + " failure! Reason: "
078:                                        + ex.getMessage());
079:                    }
080:
081:                    throw new Exception(ex);
082:                } finally {
083:                    if (doCommit) {
084:                        commitTransaction();
085:                    } else {
086:                        rollbackTransaction();
087:                    }
088:                }
089:            }
090:
091:            private void fillFilesetTable(HttpPresentationComms comms,
092:                    String user, boolean isTemplate) throws BaseException {
093:
094:                String mode = EnhydraDMConstants.MODE_DOCUMENT;
095:                if (isTemplate) {
096:                    mode = EnhydraDMConstants.MODE_TEMPLATE;
097:                }
098:
099:                Node fileRow = page.getElementDocumentRow();
100:                Document[] documents = null;
101:                documents = documentManager.getDeleted(isTemplate);
102:                SimpleDateFormat sdf = new SimpleDateFormat(
103:                        EnhydraDMConstants.DATE_FORMAT);
104:
105:                HTMLAnchorElement restoreLink = page.getElementRestoreLink();
106:                HTMLAnchorElement logoutLink = page.getElementLogoutLink();
107:                HTMLAnchorElement backLink = page.getElementBackLink();
108:                HTMLAnchorElement documentDetailLink = page
109:                        .getElementDocumentDetailLink();
110:
111:                logoutLink.setHref(EnhydraDMConstants.NAVIG_MANAGER + "?"
112:                        + EnhydraDMConstants.ACTION + "="
113:                        + EnhydraDMConstants.ACTION_LOGOUT);
114:
115:                if (isTemplate) {
116:                    page.setTextHeader("Deleted Templates");
117:                } else {
118:                    page.setTextHeader("Deleted Documents");
119:                }
120:
121:                backLink.setHref(EnhydraDMConstants.NAVIG_MANAGER + "?"
122:                        + EnhydraDMConstants.MODE + "=" + mode);
123:
124:                if (documents != null) {
125:
126:                    for (int i = 0; i < documents.length; i++) {
127:                        String documentName = documents[i].getName();
128:                        String documentId = documents[i].getNumber().toString();
129:                        long documentSize = documents[i].getSize();
130:
131:                        String appUser = documents[i].getDeletedBy();
132:
133:                        documentDetailLink
134:                                .setHref(EnhydraDMConstants.NAVIG_DETAILS + "?"
135:                                        + EnhydraDMConstants.DOCUMENT_ID + "="
136:                                        + documentId + "&"
137:                                        + EnhydraDMConstants.MODE + "=" + mode);
138:                        page.setTextDocumentName(documentName);
139:                        page.setTextDocumentId(documentId);
140:                        page.setTextDocumentSize(String.valueOf(documentSize));
141:
142:                        page.setTextDeletedBy(appUser);
143:
144:                        Date mainDate = new Date(documents[i].getDeletedDate());
145:                        if (mainDate != null) {
146:                            String strMainDate = sdf.format(mainDate);
147:                            page.setTextDeletionDate(strMainDate);
148:                        } else {
149:                            page.setTextDeletionDate("-");
150:                        }
151:
152:                        restoreLink.setHref(EnhydraDMConstants.NAVIG_RECYCLEBIN
153:                                + "?" + EnhydraDMConstants.ACTION + "="
154:                                + EnhydraDMConstants.ACTION_RESTORE + "&"
155:                                + EnhydraDMConstants.DOCUMENT_ID + "="
156:                                + documents[i].getNumber() + "&"
157:                                + EnhydraDMConstants.MODE + "=" + mode);
158:
159:                        fileRow.getParentNode().insertBefore(
160:                                fileRow.cloneNode(true), fileRow);
161:                    }
162:                }
163:                fileRow.getParentNode().removeChild(fileRow);
164:            }
165:
166:            private void restoreDocument(HttpPresentationComms comms,
167:                    String documentId, String user) throws BaseException {
168:
169:                documentManager.restore(documentId, user);
170:            }
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.