Source Code Cross Referenced for DeleteItemUtil.java in  » Content-Management-System » contineo » org » contineo » core » document » 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 » Content Management System » contineo » org.contineo.core.document 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        package org.contineo.core.document;
02:
03:        import java.util.Collection;
04:        import java.util.Iterator;
05:
06:        import org.apache.commons.logging.Log;
07:        import org.apache.commons.logging.LogFactory;
08:        import org.contineo.core.document.dao.DocumentDAO;
09:        import org.contineo.core.document.dao.TermDAO;
10:        import org.contineo.core.doxter.Storer;
11:        import org.contineo.core.searchengine.crawler.Indexer;
12:        import org.contineo.core.searchengine.dao.SearchDocumentDAO;
13:        import org.contineo.core.security.Menu;
14:        import org.contineo.core.security.dao.MenuDAO;
15:        import org.contineo.core.security.dao.UserDocDAO;
16:        import org.contineo.util.Context;
17:
18:        /**
19:         * utility class for deleting menus
20:         * 
21:         * @author Sebastian Stein
22:         */
23:        public class DeleteItemUtil {
24:            protected static Log log = LogFactory.getLog(DeleteItemUtil.class);
25:
26:            /**
27:             * deletes the given menu and all sub-menus; does not perform an access
28:             * check
29:             * 
30:             * @param menuId menu to be deleted; can be a folder, menu or document
31:             * @param userName the user requesting the delete action
32:             */
33:            public static boolean deleteMenu(int menuId, String userName) {
34:                MenuDAO mdao = (MenuDAO) Context.getInstance().getBean(
35:                        MenuDAO.class);
36:                Menu menu = mdao.findByPrimaryKey(menuId);
37:                if (menu == null)
38:                    return true;
39:                int type = menu.getMenuType();
40:                try {
41:                    if (type == Menu.MENUTYPE_FILE) {
42:                        deleteFile(menu, menuId, userName);
43:                    } else if (type == Menu.MENUTYPE_DIRECTORY) {
44:                        Collection children = mdao.findByParentId(menuId);
45:
46:                        Iterator childIter = children.iterator();
47:                        while (childIter.hasNext()) {
48:                            Menu m = (Menu) childIter.next();
49:                            deleteFile(m, m.getMenuId(), userName);
50:                        }
51:                    }
52:                    return mdao.delete(menuId);
53:                } catch (Exception ex) {
54:                    ex.printStackTrace();
55:                    log.error(ex.getMessage(), ex);
56:                    return false;
57:                }
58:            }
59:
60:            /**
61:             * deletes the given menu; does not perform an access check; only used
62:             * internally
63:             */
64:            private static void deleteFile(Menu menu, int id, String username)
65:                    throws Exception {
66:                SearchDocumentDAO searchDocDao = (SearchDocumentDAO) Context
67:                        .getInstance().getBean(SearchDocumentDAO.class);
68:                searchDocDao.deleteByMenuId(id);
69:                UserDocDAO uddao = (UserDocDAO) Context.getInstance().getBean(
70:                        UserDocDAO.class);
71:                uddao.delete(username, id);
72:                DocumentDAO ddao = (DocumentDAO) Context.getInstance().getBean(
73:                        DocumentDAO.class);
74:                Document doc = ddao.findByMenuId(id);
75:                if (doc != null) {
76:                    Indexer indexer = (Indexer) Context.getInstance().getBean(
77:                            Indexer.class);
78:                    indexer.deleteFile(String.valueOf(id), doc.getLanguage());
79:                }
80:                // int docId = doc.getDocId();
81:                boolean deleted1 = ddao.deleteByMenuId(id);
82:                TermDAO termDao = (TermDAO) Context.getInstance().getBean(
83:                        TermDAO.class);
84:                boolean deleted2 = termDao.delete(id);
85:                MenuDAO mdao = (MenuDAO) Context.getInstance().getBean(
86:                        MenuDAO.class);
87:                boolean deleted = mdao.delete(id);
88:                // String path = conf.getValue("docdir");
89:                String menupath = menu.getMenuPath() + "/" + String.valueOf(id);
90:                // FileBean.deleteDir(path);
91:                Storer storer = (Storer) Context.getInstance().getBean(
92:                        Storer.class);
93:                if (!storer.delete(menupath) || !deleted || !deleted1
94:                        || !deleted2)
95:                    throw new Exception();
96:            }
97:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.