KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > common > XMLMarshaller


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/share/org/apache/slide/common/XMLMarshaller.java,v 1.11 2004/07/28 09:38:08 ib Exp $
3  * $Revision: 1.11 $
4  * $Date: 2004/07/28 09:38:08 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.common;
25
26 import java.io.Writer JavaDoc;
27
28 /**
29  * XMLMarshaller helper class.
30  *
31  * @version $Revision: 1.11 $
32  */

33 public final class XMLMarshaller {
34     
35     
36     // --------------------------------------------------------- Public Methods
37

38     
39     /**
40      * Saves Slide Data to XML.
41      *
42      * @param writer Writer
43      * @param startNode Start generating XML from this node of the Slide tree
44      * @exception SlideException
45      */

46     public static void marshal(NamespaceAccessToken accessToken,
47                                SlideToken token, Writer JavaDoc writer,
48                                String JavaDoc startNode)
49     throws SlideException {
50         /*
51     try {
52         // Retrieve the start element
53         ObjectNode object =
54                 accessToken.getStructureHelper().retrieve(token, startNode);
55         // Generate an associated Castor object representing the ObjectNode
56         org.apache.slide.common.xml.Objectnode slideObjectDef =
57         new org.apache.slide.common.xml.Objectnode();
58         saveObjectNode(accessToken, token, object, slideObjectDef);
59         // Marshal the Castor object to the Writer
60         slideObjectDef.marshal(writer);
61     } catch (Exception e) {
62         e.printStackTrace();
63     }
64     */

65     }
66     
67     
68     // -------------------------------------------------------- Private Methods
69

70     
71     /**
72      * Save a ObjectNode to a Castor ObjectNode.
73      *
74      * @param object Slide Object
75      * @param objectDef Castor ObjectNode definition
76      */

77     /*
78     private static void saveObjectNode
79         (NamespaceAccessToken accessToken, CredentialsToken token,
80          ObjectNode object, org.apache.slide.common.xml.Objectnode objectDef) {
81         
82         // Set the basic fields of the Castor object
83         objectDef.setClassname(object.getClass().getName());
84         objectDef.setUri(object.getUri().toString());
85         
86         // If the object is or derives from the LinkNode class, we must also
87         // save it's additional linkedUri field
88         if (object instanceof LinkNode) {
89             objectDef.setTarget(((LinkNode) object).getLinkedUri().toString());
90     }
91         
92         try {
93             // Save permissions associated with the Slide Object
94             Enumeration permissions = accessToken.getSecurityHelper()
95                 .enumeratePermissions(token, object);
96             while (permissions.hasMoreElements()) {
97                 NodePermission permission =
98                     (NodePermission) permissions.nextElement();
99                 org.apache.slide.common.xml.Permission permissionDef =
100                     new org.apache.slide.common.xml.Permission();
101                 permissionDef.setSubject
102                     (permission.getSubjectUri().toString());
103                 permissionDef.setAction(permission.getActionUri().toString());
104                 permissionDef.setInheritance
105                     ((new Boolean(permission.isInheritable())).toString());
106                 objectDef.addPermission(permissionDef);
107             }
108     */

109             // Saving version information
110
/*
111               SlideProperties properties = accessToken.getStructureHelper()
112               .retrieve(token, object);
113               org.apache.slide.common.xml.Properties propertiesDef =
114               new org.apache.slide.common.xml.Properties();
115               
116               propertiesDef.setContentlanguage
117               (properties.getContentLanguage());
118               propertiesDef.setContenttype(properties.getContentType());
119               if (properties.getCreationDateAsDate() != null) {
120               propertiesDef.setCreationdate
121               ((new Long(properties.getCreationDateAsDate()
122               .getTime())).toString());
123               } else {
124               propertiesDef.setCreationdate(properties.getCreationDate());
125               }
126               //propertiesDef.setLatestrevisionid(properties
127               //.getLatestRevisionId().toString());
128               propertiesDef.setName(properties.getName());
129               
130               Enumeration revisionIdsList = accessToken.getContentHelper()
131               .enumerate(token, properties);
132               while (revisionIdsList.hasMoreElements()) {
133               SlideRevisionId revisionId =
134               (SlideRevisionId) revisionIdsList.nextElement();
135               SlideRevision revision = accessToken.getContentHelper()
136               .retrieve(token, properties, revisionId);
137               
138               org.apache.slide.common.xml.Revision revisionDef =
139               new org.apache.slide.common.xml.Revision();
140               
141               revisionDef.setAuthor(revision.getAuthor());
142               revisionDef.setCreationdate
143               ((new Long(revision.getCreationDate().getTime())).toString());
144               revisionDef.setId(revision.getId().toString());
145               revisionDef.setName(revision.getName());
146               propertiesDef.addRevision(revisionDef);
147               }
148               objectDef.setProperties(propertiesDef);
149             */

150     /*
151       } catch(SlideException e) {
152     }
153     
154     // Now, we parse all the children of this object
155     try {
156         Enumeration childObjects = accessToken
157                 .getStructureHelper().getChildren(token, object);
158         while (childObjects.hasMoreElements()) {
159         ObjectNode currentObject =
160                     (ObjectNode) childObjects.nextElement();
161         org.apache.slide.common.xml.Objectnode currentObjectDef =
162             new org.apache.slide.common.xml.Objectnode();
163         // Recursive call to this function
164         saveObjectNode(accessToken, token, currentObject,
165                                currentObjectDef);
166         objectDef.addObjectnode(currentObjectDef);
167         }
168     } catch(SlideException e) {
169     }
170     
171     }
172 */

173 }
174
Popular Tags