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


001:        package org.enhydra.dm.business;
002:
003:        import java.sql.SQLException;
004:        import java.util.Iterator;
005:        import java.util.Map;
006:
007:        import org.enhydra.dm.api.FoDocument;
008:        import org.enhydra.dm.api.FoDocumentManager;
009:        import org.enhydra.dm.api.FoDocumentParam;
010:        import org.enhydra.dm.api.exceptions.BaseException;
011:        import org.enhydra.dm.api.loggers.Log;
012:        import org.enhydra.dm.business.exceptions.DatabaseException;
013:        import org.enhydra.dm.data.FoDocumentDO;
014:        import org.enhydra.dm.data.FoDocumentParamDO;
015:        import org.enhydra.dm.data.FoDocumentParamQuery;
016:        import org.enhydra.dm.data.FoDocumentQuery;
017:
018:        import com.lutris.appserver.server.sql.DBRowUpdateException;
019:        import com.lutris.appserver.server.sql.DatabaseManagerException;
020:        import com.lutris.dods.builder.generator.query.DataObjectException;
021:        import com.lutris.dods.builder.generator.query.NonUniqueQueryException;
022:        import com.lutris.dods.builder.generator.query.QueryException;
023:        import com.lutris.dods.builder.generator.query.RefAssertionException;
024:
025:        public class FoDocumentManagerImpl implements  FoDocumentManager {
026:
027:            private Log logger = null;
028:
029:            /**
030:             * Empty constructor
031:             */
032:            public FoDocumentManagerImpl() {
033:
034:            }
035:
036:            /**
037:             * @param parameters
038:             * @param userPwd
039:             * @param ownerPwd
040:             * @param allowPrint
041:             * @param allowCopyContent
042:             * @param allowEditContent
043:             * @param allowEditAnnotations
044:             * @return foDocumentId
045:             * @throws BaseException
046:             */
047:            public String create(Map parameters, String userPwd,
048:                    String ownerPwd, boolean allowPrint,
049:                    boolean allowCopyContent, boolean allowEditContent,
050:                    boolean allowEditAnnotation) throws BaseException {
051:                if (null != getLogger()) {
052:                    getLogger().log(Log.DEBUG, "Create action for foDocument.");
053:                }
054:
055:                try {
056:
057:                    FoDocument foDocument = new FoDocumentImpl();
058:                    foDocument.setUserPassword(userPwd);
059:                    foDocument.setOwnerPassword(ownerPwd);
060:                    foDocument.setAllowPrint(allowPrint);
061:                    foDocument.setAllowCopyContent(allowCopyContent);
062:                    foDocument.setAllowEditContent(allowEditContent);
063:                    foDocument.setAllowEditAnnotation(allowEditAnnotation);
064:
065:                    FoDocumentDO foDocumentDO = null;
066:
067:                    foDocumentDO = foDocument.createDO();
068:                    foDocumentDO.save();
069:
070:                    Iterator entries = parameters.entrySet().iterator();
071:
072:                    while (entries.hasNext()) {
073:                        try {
074:                            Map.Entry me = (Map.Entry) entries.next();
075:                            String name = (String) me.getKey();
076:                            String value = (String) me.getValue();
077:                            if (value != null) {
078:                                FoDocumentParam foDocumentParam = new FoDocumentParamImpl();
079:                                foDocumentParam.setName(name);
080:                                foDocumentParam.setContent(value);
081:                                FoDocumentParamDO fdpDO = foDocumentParam
082:                                        .createDO();
083:                                fdpDO.setFODOCUMENTREF(foDocumentDO);
084:                                fdpDO.save();
085:                            }
086:                        } catch (Exception ex) {
087:                            throw new DatabaseException(
088:                                    "Failed to create FoDocument Parameter entry!");
089:                        }
090:                    }
091:
092:                    if (null != getLogger()) {
093:                        getLogger().log(Log.DEBUG, "foDocument is created.");
094:                    }
095:                    return foDocumentDO.get_OId().toString();
096:
097:                } catch (DatabaseManagerException e) {
098:                    throw new DatabaseException(e);
099:                } catch (DataObjectException e) {
100:                    throw new DatabaseException(e);
101:                } catch (RefAssertionException e) {
102:                    throw new DatabaseException(e);
103:                } catch (DBRowUpdateException e) {
104:                    throw new DatabaseException(e);
105:                } catch (QueryException e) {
106:                    throw new DatabaseException(e);
107:                } catch (SQLException e) {
108:                    throw new DatabaseException(e);
109:                }
110:            }
111:
112:            /**
113:             * Getter for logger
114:             * 
115:             * @return
116:             */
117:            public Log getLogger() {
118:                return logger;
119:            }
120:
121:            /**
122:             * Setter for logger
123:             * 
124:             * @param logger
125:             */
126:            public void setLogger(Log logger) {
127:                this .logger = logger;
128:            }
129:
130:            /**
131:             * @param id
132:             * @return
133:             * @throws BaseException
134:             */
135:            public FoDocument getFoDocumentById(String id) throws BaseException {
136:                FoDocument foDocument = null;
137:                foDocument = new FoDocumentImpl(getFoDocumentDO(id));
138:
139:                return foDocument;
140:            }
141:
142:            public FoDocumentParam[] getFoDocumentParametersById(String id)
143:                    throws BaseException {
144:                FoDocumentParamDO[] foDocumentParamDOArray = null;
145:                FoDocumentParam[] foDocumentParamArray = null;
146:                FoDocumentParamQuery foDocumentParamQuery = new FoDocumentParamQuery();
147:                ;
148:
149:                try {
150:                    foDocumentParamQuery
151:                            .setQueryFODOCUMENTREF(getFoDocumentDO(id));
152:                    foDocumentParamDOArray = foDocumentParamQuery.getDOArray();
153:
154:                } catch (DataObjectException e) {
155:                    throw new DatabaseException(e);
156:                } catch (QueryException e) {
157:                    throw new DatabaseException(e);
158:                } catch (NonUniqueQueryException e) {
159:                    throw new DatabaseException(e);
160:                }
161:                if (foDocumentParamDOArray == null) {
162:                    throw new DatabaseException(
163:                            "FoDocument parameters not found (ID) - " + id);
164:                }
165:
166:                foDocumentParamArray = new FoDocumentParam[foDocumentParamDOArray.length];
167:                for (int i = 0; i < foDocumentParamDOArray.length; i++) {
168:                    foDocumentParamArray[i] = new FoDocumentParamImpl(
169:                            foDocumentParamDOArray[i]);
170:                }
171:
172:                return foDocumentParamArray;
173:            }
174:
175:            /**
176:             * @param id
177:             * @return
178:             * @throws BaseException
179:             */
180:            private FoDocumentDO getFoDocumentDO(String id)
181:                    throws BaseException {
182:                if (null != getLogger()) {
183:                    getLogger().log(Log.DEBUG,
184:                            "Getting the foDocuments from database!");
185:                }
186:
187:                FoDocumentDO foDocumentDO = FoDocumentDO.createExisting(id);
188:
189:                if (foDocumentDO == null) {
190:                    throw new DatabaseException("FoDocument not found (ID) - "
191:                            + id);
192:                }
193:
194:                return foDocumentDO;
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.