Source Code Cross Referenced for FullBackupDataWriter.java in  » Database-ORM » MMBase » org » mmbase » util » xml » applicationdata » 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 » Database ORM » MMBase » org.mmbase.util.xml.applicationdata 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:        This software is OSI Certified Open Source Software.
004:        OSI Certified is a certification mark of the Open Source Initiative.
005:
006:        The license (Mozilla version 1.0) can be read at the MMBase site.
007:        See http://www.MMBase.org/license
008:
009:         */
010:        package org.mmbase.util.xml.applicationdata;
011:
012:        import java.io.File;
013:        import java.util.*;
014:
015:        import org.mmbase.storage.search.*;
016:        import org.mmbase.storage.search.implementation.*;
017:        import org.mmbase.module.core.*;
018:        import org.mmbase.module.corebuilders.InsRel;
019:        import org.mmbase.util.logging.*;
020:        import org.mmbase.util.xml.ApplicationReader;
021:
022:        /**
023:         * This is used to export a full backup, by writing all nodes to XML.
024:         *
025:         * @since MMBase-1.8
026:         * @author Pierre van Rooden
027:         * @version $Id: FullBackupDataWriter.java,v 1.8 2007/02/25 17:56:58 nklasens Exp $
028:         */
029:        public class FullBackupDataWriter {
030:
031:            /**
032:             * Logging instance
033:             */
034:            private static Logger log = Logging
035:                    .getLoggerInstance(FullBackupDataWriter.class);
036:
037:            /**
038:             * Writes all nodes to XML.
039:             * @param reader A <code>ApplicationReader</code> initialised to read the application's description (xml) file
040:             * @param targetPath The path where to save the application
041:             * @param mmbase Reference to the MMbase processormodule. Used to retrieve the nodes to write.
042:             * @param logger Storage for messages which can be displayed to the user.
043:             * @throws IOException if a file could not be written
044:             * @throws SearchQueryException if data could not be obtained from the database
045:             */
046:            public static void writeContext(ApplicationReader reader,
047:                    String targetPath, MMBase mmbase, Logger logger)
048:                    throws SearchQueryException {
049:                // Create directory for data files.
050:                String subTargetPath = targetPath + "/" + reader.getName()
051:                        + "/";
052:                File file = new File(subTargetPath);
053:                file.mkdirs();
054:                // Write the nodes
055:                writeNodes(subTargetPath, mmbase, logger);
056:                logger.info("Full backup finished.");
057:            }
058:
059:            /**
060:             * Searches the MMBase cloud, collecting all nodes and storing them in data files.
061:             *
062:             * @param targetPath The path where to save the application data
063:             * @param mmb MMBase object used to retrieve builder information
064:             * @param logger Storage for messages which can be displayed to the user.
065:             * @throws IOException if a file could not be written
066:             * @throws SearchQueryException if data could not be obtained from the database
067:             */
068:            static void writeNodes(String subTargetPath, MMBase mmbase,
069:                    Logger logger) throws SearchQueryException {
070:                for (Object element : mmbase.getBuilders()) {
071:                    MMObjectBuilder builder = (MMObjectBuilder) element;
072:
073:                    // Skip virtual builders and a set of system builders
074:                    String builderName = builder.getTableName();
075:                    if (builder.isVirtual() || builderName.equals("reldef")
076:                            || builderName.equals("typerel")
077:                            || builderName.equals("versions")
078:                            || builderName.equals("syncnodes")
079:                            || builderName.equals("daymarks")
080:                            || builderName.equals("oalias")
081:                            || builderName.equals("icaches")) {
082:                        continue;
083:                    }
084:                    boolean isRelation = builder instanceof  InsRel;
085:
086:                    NodeSearchQuery query = new NodeSearchQuery(builder);
087:                    StepField otypeField = query.getField(builder
088:                            .getField(MMObjectBuilder.FIELD_OBJECT_TYPE));
089:                    BasicFieldValueConstraint constraint = new BasicFieldValueConstraint(
090:                            otypeField, builder.getObjectType());
091:                    query.setConstraint(constraint);
092:
093:                    // Add this builder's nodes to set (by nodenumber).
094:                    List<MMObjectNode> nodes = builder.getStorageConnector()
095:                            .getNodes(query, false);
096:                    writeNodes(subTargetPath, mmbase, logger, builder, nodes,
097:                            isRelation);
098:                }
099:            }
100:
101:            /**
102:             * Writes the nodes of a particular type to the corresponding XML file.
103:             * @param builder The builder.
104:             * @param nodes The nodes, must type corresponding to the builder.
105:             * @param subTargetPath Path where the XML file is written.
106:             * @param mmb MMBase object used to retrieve builder information
107:             * @param logger Used to store messages that can be shown to the user
108:             * @param isRelation Indicates whether the nodes to write are data (false) or relation (true) nodes
109:             */
110:            static void writeNodes(String subTargetPath, MMBase mmbase,
111:                    Logger logger, MMObjectBuilder builder,
112:                    List<MMObjectNode> nodes, boolean isRelation) {
113:
114:                // Create nodewriter for this builder
115:                NodeWriter nodeWriter = new NodeWriter(mmbase, logger,
116:                        subTargetPath, builder.getTableName(), isRelation);
117:
118:                Iterator<MMObjectNode> iNodes = nodes.iterator();
119:                int nrWritten = 0;
120:                while (iNodes.hasNext()) {
121:                    MMObjectNode node = iNodes.next();
122:                    // Write node if it's of the correct type.
123:                    if (node.getBuilder() == builder) {
124:                        nodeWriter.write(node);
125:                        nrWritten++;
126:                    }
127:                }
128:                nodeWriter.done();
129:
130:                log.debug("Builder " + builder.getTableName() + ": "
131:                        + nrWritten + (isRelation ? " relations" : " nodes")
132:                        + " written.");
133:            }
134:
135:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.