Source Code Cross Referenced for UploadMetadata.java in  » IDE-Netbeans » xtest » org » netbeans » xtest » pes » dbfeeder » 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 » IDE Netbeans » xtest » org.netbeans.xtest.pes.dbfeeder 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.xtest.pes.dbfeeder;
043:
044:        import org.netbeans.xtest.xmlserializer.*;
045:        import java.sql.*;
046:        import java.io.*;
047:        import org.netbeans.xtest.util.NetUtils;
048:        import java.text.SimpleDateFormat;
049:
050:        import org.w3c.dom.Document;
051:        import org.netbeans.xtest.util.SerializeDOM;
052:
053:        public class UploadMetadata implements  XMLSerializable {
054:
055:            static ClassMappingRegistry classMappingRegistry = new ClassMappingRegistry(
056:                    UploadMetadata.class);
057:            static {
058:                try {
059:                    // load global registry
060:                    GlobalMappingRegistry.registerClassForElementName(
061:                            "PESdbUpload", UploadMetadata.class);
062:                    // register this class
063:                    //classMappingRegistry.registerSimpleField("team",ClassMappingRegistry.ATTRIBUTE,"team");
064:                    classMappingRegistry.registerSimpleField("mailContact",
065:                            ClassMappingRegistry.ATTRIBUTE, "mailContact");
066:                    classMappingRegistry.registerSimpleField("timestamp",
067:                            ClassMappingRegistry.ATTRIBUTE, "timestamp");
068:                    classMappingRegistry.registerContainerField("uploadedZips",
069:                            "uploadedZips", ClassMappingRegistry.SUBELEMENT);
070:                    classMappingRegistry.registerContainerSubtype(
071:                            "uploadedZips", String.class, "zipFile");
072:                    classMappingRegistry.registerContainerField("webs",
073:                            "PESStatus", ClassMappingRegistry.SUBELEMENT);
074:                    classMappingRegistry.registerContainerSubtype("webs",
075:                            WebStatus.class, "web");
076:                } catch (MappingException me) {
077:                    me.printStackTrace();
078:                    classMappingRegistry = null;
079:                }
080:            }
081:
082:            public ClassMappingRegistry registerXMLMapping() {
083:                return classMappingRegistry;
084:            }
085:
086:            // empty constructor - required by XMLSerializer
087:            public UploadMetadata() {
088:            }
089:
090:            public UploadMetadata(String mailContact) {
091:                this .mailContact = mailContact;
092:                this .timestamp = new Timestamp(System.currentTimeMillis());
093:            }
094:
095:            public static UploadMetadata loadUploadMetadata(File metadataFile)
096:                    throws XMLSerializeException {
097:                if (!metadataFile.isFile()) {
098:                    throw new XMLSerializeException(
099:                            "Cannot load UploadMetadata from file "
100:                                    + metadataFile.getPath()
101:                                    + ", file does not exist");
102:                }
103:                try {
104:                    Document doc = SerializeDOM.parseFile(metadataFile);
105:                    XMLSerializable xmlObject = XMLSerializer
106:                            .getXMLSerializable(doc);
107:                    if (xmlObject instanceof  UploadMetadata) {
108:                        UploadMetadata metadata = (UploadMetadata) xmlObject;
109:                        return metadata;
110:                    }
111:                } catch (IOException ioe) {
112:                    throw new XMLSerializeException(
113:                            "IOException caught when loading UploadMetadata file:"
114:                                    + metadataFile.getPath(), ioe);
115:                }
116:                // xmlobject is not of required type
117:                throw new XMLSerializeException(
118:                        "Loaded xml document is not UploadMetadata");
119:            }
120:
121:            public void saveUploadMetadata(File metadataFile)
122:                    throws XMLSerializeException {
123:                try {
124:                    Document doc = XMLSerializer.toDOMDocument(this );
125:                    SerializeDOM.serializeToFile(doc, metadataFile);
126:                } catch (IOException ioe) {
127:                    throw new XMLSerializeException(
128:                            "IOException caught when saving UploadMetadata file:"
129:                                    + metadataFile.getPath(), ioe);
130:                } catch (javax.xml.parsers.ParserConfigurationException pce) {
131:                    throw new XMLSerializeException(
132:                            "ParserConfigurationException caught when saving UploadMetadata file:"
133:                                    + metadataFile.getPath(), pce);
134:                }
135:            }
136:
137:            private String mailContact;
138:
139:            /*
140:             private String team;
141:            public String getTeam() {
142:                return team;
143:            }    
144:             */
145:
146:            private Timestamp timestamp;
147:
148:            private String[] uploadedZips;
149:
150:            private WebStatus[] webs;
151:
152:            /** Getter for property mailContact.
153:             * @return Value of property mailContact.
154:             *
155:             */
156:            public java.lang.String getMailContact() {
157:                return mailContact;
158:            }
159:
160:            /** Getter for property timestamp.
161:             * @return Value of property timestamp.
162:             *
163:             */
164:            public java.sql.Timestamp getTimestamp() {
165:                return timestamp;
166:            }
167:
168:            /** Setter for property timestamp.
169:             * @param timestamp New value of property timestamp.
170:             *
171:             */
172:            /*
173:            public void setTimestamp(java.sql.Timestamp timestamp) {
174:                this.timestamp = timestamp;
175:            }
176:            /*
177:            /** Getter for property uploadedZips.
178:             * @return Value of property uploadedZips.
179:             *
180:             */
181:            public java.lang.String[] getUploadedZipFilenames() {
182:                if (uploadedZips == null) {
183:                    uploadedZips = new String[0];
184:                }
185:                return this .uploadedZips;
186:            }
187:
188:            /** get uploaded zips as file objects
189:             */
190:            public File[] getUploadedZipFiles(File parentDir) {
191:                File[] zips = new File[getUploadedZipFilenames().length];
192:                for (int i = 0; i < uploadedZips.length; i++) {
193:                    zips[i] = new File(parentDir, uploadedZips[i].trim());
194:                }
195:                return zips;
196:            }
197:
198:            /** Setter for property uploadedZips.
199:             * @param uploadedZips New value of property uploadedZips.
200:             *
201:             */
202:            public void setUploadedZips(java.lang.String[] uploadedZips) {
203:                this .uploadedZips = uploadedZips;
204:            }
205:
206:            public void setUploadedZips(File[] uploadedZips) {
207:                String[] zipNames = new String[uploadedZips.length];
208:                for (int i = 0; i < uploadedZips.length; i++) {
209:                    zipNames[i] = uploadedZips[i].getName();
210:                }
211:                this .uploadedZips = zipNames;
212:            }
213:
214:            /* removes uploaded zip from the array 
215:             *
216:             */
217:            public boolean removeUploadedZip(String uploadedZip) {
218:                if (uploadedZips != null) {
219:                    for (int i = 0; i < uploadedZips.length; i++) {
220:                        if (uploadedZip.equals(uploadedZips[i])) {
221:                            uploadedZips[i] = null;
222:                            // the array should be shrinked as well
223:                            return true;
224:                        }
225:                    }
226:                }
227:                return false;
228:            }
229:
230:            public boolean removeUploadedZip(File uploadedZip) {
231:                return removeUploadedZip(uploadedZip.getName());
232:            }
233:
234:            public String getMetadataFilename() {
235:                String hostname = NetUtils.getLocalHostName();
236:                SimpleDateFormat formatter = new SimpleDateFormat(
237:                        "yyMMdd-HHmmss");
238:                String timestamp = formatter.format(this .timestamp);
239:                return "pes-" + NetUtils.getLocalHostName() + "-" + timestamp
240:                        + ".xml";
241:            }
242:
243:            /** Getter for property web.
244:             * @return Value of property web.
245:             *
246:             */
247:            public WebStatus[] getWebs() {
248:                return this .webs;
249:            }
250:
251:            /** Setter for property web.
252:             * @param web New value of property web.
253:             *
254:             */
255:            public void setWebs(WebStatus[] webs) {
256:                this.webs = webs;
257:            }
258:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.