Source Code Cross Referenced for ManageRegistries.java in  » IDE-Netbeans » nbi » org » netbeans » installer » infra » server » admin » servlets » 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 » nbi » org.netbeans.installer.infra.server.admin.servlets 
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 General
007:         * Public License Version 2 only ("GPL") or the Common Development and Distribution
008:         * License("CDDL") (collectively, the "License"). You may not use this file except in
009:         * compliance with the License. You can obtain a copy of the License at
010:         * http://www.netbeans.org/cddl-gplv2.html or nbbuild/licenses/CDDL-GPL-2-CP. See the
011:         * License for the specific language governing permissions and limitations under the
012:         * License.  When distributing the software, include this License Header Notice in
013:         * each file and include the License file at nbbuild/licenses/CDDL-GPL-2-CP.  Sun
014:         * designates this particular file as subject to the "Classpath" exception as
015:         * provided by Sun in the GPL Version 2 section of the License file that
016:         * accompanied this code. If applicable, add the following below the License Header,
017:         * with the fields enclosed by brackets [] replaced by your own identifying
018:         * information: "Portions Copyrighted [year] [name of copyright owner]"
019:         * 
020:         * Contributor(s):
021:         * 
022:         * The Original Software is NetBeans. The Initial Developer of the Original Software
023:         * is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun Microsystems, Inc. All
024:         * Rights Reserved.
025:         * 
026:         * If you wish your version of this file to be governed by only the CDDL or only the
027:         * GPL Version 2, indicate your decision by adding "[Contributor] elects to include
028:         * this software in this distribution under the [CDDL or GPL Version 2] license." If
029:         * you do not indicate a single choice of license, a recipient has the option to
030:         * distribute your version of this file under either the CDDL, the GPL Version 2 or
031:         * to extend the choice of license to its licensees as provided above. However, if
032:         * you add GPL Version 2 code and therefore, elected the GPL Version 2 license, then
033:         * the option applies only if the new code is made subject to such option by the
034:         * copyright holder.
035:         */
036:
037:        package org.netbeans.installer.infra.server.admin.servlets;
038:
039:        import java.io.IOException;
040:        import java.io.PrintWriter;
041:        import java.util.ArrayList;
042:        import java.util.List;
043:        import javax.ejb.EJB;
044:        import javax.servlet.ServletException;
045:        import javax.servlet.http.HttpServlet;
046:        import javax.servlet.http.HttpServletRequest;
047:        import javax.servlet.http.HttpServletResponse;
048:        import org.netbeans.installer.infra.server.ejb.Manager;
049:        import org.netbeans.installer.infra.server.ejb.ManagerException;
050:        import org.netbeans.installer.product.components.Product;
051:        import org.netbeans.installer.product.components.Group;
052:        import org.netbeans.installer.product.RegistryNode;
053:        import org.netbeans.installer.utils.StringUtils;
054:        import org.netbeans.installer.utils.SystemUtils;
055:        import org.netbeans.installer.utils.exceptions.ParseException;
056:        import org.netbeans.installer.utils.helper.Platform;
057:
058:        /**
059:         *
060:         * @author ks152834
061:         * @version
062:         */
063:        public class ManageRegistries extends HttpServlet {
064:            @EJB
065:            private Manager manager;
066:
067:            protected void processRequest(HttpServletRequest request,
068:                    HttpServletResponse response) throws ServletException,
069:                    IOException {
070:                response.setContentType("text/html; charset=UTF-8");
071:
072:                final PrintWriter out = response.getWriter();
073:
074:                try {
075:                    final List<String> registries = manager.getRegistries();
076:                    final String userAgent = request.getHeader("User-Agent");
077:
078:                    Platform platform = SystemUtils.getCurrentPlatform();
079:                    if (userAgent.contains("Windows")) {
080:                        platform = Platform.WINDOWS;
081:                    }
082:                    if (userAgent.contains("PPC Mac OS")) {
083:                        platform = Platform.MACOSX_PPC;
084:                    }
085:                    if (userAgent.contains("Intel Mac OS")) {
086:                        platform = Platform.MACOSX_X86;
087:                    }
088:                    if (userAgent.contains("Linux")) {
089:                        platform = Platform.LINUX;
090:                    }
091:                    if (userAgent.contains("SunOS i86pc")) {
092:                        platform = Platform.SOLARIS_X86;
093:                    }
094:                    if (userAgent.contains("SunOS sun4u")) {
095:                        platform = Platform.SOLARIS_SPARC;
096:                    }
097:
098:                    if (request.getParameter("platform") != null) {
099:                        try {
100:                            platform = StringUtils.parsePlatform(request
101:                                    .getParameter("platform"));
102:                        } catch (ParseException e) {
103:                            e.printStackTrace(out);
104:                        }
105:                    }
106:
107:                    out
108:                            .println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
109:                    out.println("<html>");
110:                    out.println("    <head>");
111:                    out
112:                            .println("        <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>");
113:                    out.println("        <title>Registries Manager</title>");
114:                    out
115:                            .println("        <link rel=\"stylesheet\" href=\"css/main.css\" type=\"text/css\"/>");
116:                    out
117:                            .println("        <script src=\"js/main.js\" type=\"text/javascript\"></script>");
118:                    out.println("    </head>");
119:                    out
120:                            .println("    <body onload=\"update_current_registry()\">");
121:                    out.println("        <div class=\"top-menu\">");
122:                    out
123:                            .println("            <a href=\"javascript: add_registry();\">Add Registry</a> |");
124:                    if (registries.size() > 0) {
125:                        out
126:                                .println("            <a href=\"javascript: remove_registry();\">Remove Registry</a> |");
127:                        out
128:                                .println("            <a href=\"javascript: delete_bundles();\">Delete Bundles</a> | ");
129:                        out
130:                                .println("            <a href=\"javascript: generate_bundles();\">Generate Bundles</a> | ");
131:                        out
132:                                .println("            <a href=\"javascript: export_registry();\">Export Registry</a> | ");
133:                    } else {
134:                        out.println("            Remove Registry |");
135:                        out.println("            Delete Bundles | ");
136:                        out.println("            Generate Bundles | ");
137:                        out.println("            Export Registry | ");
138:                    }
139:                    out
140:                            .println("            <a href=\"javascript: update_engine();\">Update Engine</a>");
141:                    out.println("        </div>");
142:                    out.println("        ");
143:                    if (registries.size() == 0) {
144:                        out.println("        <p>");
145:                        out
146:                                .println("            Currently there are no existing registries on this server.");
147:                        out.println("        </p>");
148:                    } else {
149:                        String selected = request.getParameter("registry");
150:
151:                        out
152:                                .println("        <select id=\"registries-select\" onchange=\"update_current_registry()\">");
153:                        for (String registry : registries) {
154:                            out.println("            <option value=\""
155:                                    + registry
156:                                    + "\""
157:                                    + (registry.equals(selected) ? " selected"
158:                                            : "") + ">" + registry
159:                                    + "</option>");
160:                        }
161:                        out.println("        </select>");
162:
163:                        out
164:                                .println("        <select id=\"platforms-select\" onchange=\"update_target_platform()\">");
165:                        for (Platform temp : Platform.values()) {
166:                            out
167:                                    .println("            <option value=\""
168:                                            + temp.getCodeName()
169:                                            + "\""
170:                                            + (temp.equals(platform) ? " selected"
171:                                                    : "") + ">"
172:                                            + temp.getDisplayName()
173:                                            + "</option>");
174:                        }
175:                        out.println("        </select>");
176:
177:                        for (String registry : registries) {
178:                            out
179:                                    .println("        <div class=\"registry\" id=\"registry-"
180:                                            + registry + "\">");
181:
182:                            buildRegistryTable(out, registry, manager
183:                                    .loadRegistry(registry).getRegistryRoot(),
184:                                    platform);
185:
186:                            out.println("        </div>");
187:                        }
188:                    }
189:                    out.println("        ");
190:                    out
191:                            .println("        <form name=\"Form\" method=\"post\" enctype=\"multipart/form-data\">");
192:                    out
193:                            .println("            <input type=\"hidden\" name=\"fallback_base\" value=\""
194:                                    + request.getRequestURL() + "\"/>");
195:                    out
196:                            .println("            <input type=\"hidden\" name=\"fallback\"/>");
197:                    out
198:                            .println("            <input type=\"hidden\" name=\"uid\"/>");
199:                    out
200:                            .println("            <input type=\"hidden\" name=\"version\"/>");
201:                    out
202:                            .println("            <input type=\"hidden\" name=\"platforms\"/>");
203:                    out
204:                            .println("            <div class=\"pop-up\" id=\"form-registry\">");
205:                    out.println("                <table>");
206:                    out.println("                    <tr>");
207:                    out
208:                            .println("                        <td colspan=\"2\">Please define a name for a new registry.</td>");
209:                    out.println("                    </tr>");
210:                    out.println("                    <tr>");
211:                    out
212:                            .println("                        <td style=\"width: 100%\"><input type=\"text\" name=\"registry\" style=\"width: 100%\"/></td>");
213:                    out
214:                            .println("                        <td><input type=\"submit\"/></td>");
215:                    out.println("                    </tr>");
216:                    out.println("                    <tr>");
217:                    out
218:                            .println("                        <td colspan=\"2\"><a href=\"javascript: close_form_registry()\">close window</a></td>");
219:                    out.println("                    </tr>");
220:                    out.println("                </table>");
221:                    out.println("            </div>");
222:                    out
223:                            .println("            <div class=\"pop-up\" id=\"form-codebase\">");
224:                    out.println("                <table>");
225:                    out.println("                    <tr>");
226:                    out
227:                            .println("                        <td colspan=\"2\">Please define the URL prefix for the export.</td>");
228:                    out.println("                    </tr>");
229:                    out.println("                    <tr>");
230:                    out
231:                            .println("                        <td style=\"width: 100%\"><input type=\"text\" name=\"codebase\" style=\"width: 100%\"/></td>");
232:                    out
233:                            .println("                        <td><input type=\"submit\"/></td>");
234:                    out.println("                    </tr>");
235:                    out.println("                    <tr>");
236:                    out
237:                            .println("                        <td colspan=\"2\"><a href=\"javascript: close_form_codebase()\">close window</a></td>");
238:                    out.println("                    </tr>");
239:                    out.println("                </table>");
240:                    out.println("            </div>");
241:                    out
242:                            .println("            <div class=\"pop-up\" id=\"form-archive\">");
243:                    out.println("                <table>");
244:                    out.println("                    <tr>");
245:                    out
246:                            .println("                        <td colspan=\"2\">Please point to a package.</td>");
247:                    out.println("                    </tr>");
248:                    out.println("                    <tr>");
249:                    out
250:                            .println("                        <td style=\"width: 100%\"><input type=\"file\" name=\"archive\" style=\"width: 100%\"/></td>");
251:                    out
252:                            .println("                        <td><input type=\"submit\"/></td>");
253:                    out.println("                    </tr>");
254:                    out.println("                    <tr>");
255:                    out
256:                            .println("                        <td colspan=\"2\"><a href=\"javascript: close_form_archive()\">close window</a></td>");
257:                    out.println("                    </tr>");
258:                    out.println("                </table>");
259:                    out.println("            </div>");
260:                    out.println("        </form>");
261:                    out.println("        <p class=\"small\">" + userAgent
262:                            + "</p>");
263:                    out.println("    </body>");
264:                    out.println("</html>");
265:
266:                } catch (ManagerException e) {
267:                    e.printStackTrace(out);
268:                }
269:
270:                out.close();
271:            }
272:
273:            protected void doGet(HttpServletRequest request,
274:                    HttpServletResponse response) throws ServletException,
275:                    IOException {
276:                processRequest(request, response);
277:            }
278:
279:            protected void doPost(HttpServletRequest request,
280:                    HttpServletResponse response) throws ServletException,
281:                    IOException {
282:                processRequest(request, response);
283:            }
284:
285:            private void buildRegistryTable(PrintWriter out, String registry,
286:                    RegistryNode root, Platform platform) {
287:                out.println("            <table class=\"registry\">");
288:
289:                final ArrayList<RegistryNode> nodes = new ArrayList<RegistryNode>();
290:                nodes.add(root);
291:
292:                buildRegistryNodes(out, registry, nodes, platform);
293:
294:                out.println("            </table>");
295:            }
296:
297:            private void buildRegistryNodes(PrintWriter out, String registry,
298:                    List<RegistryNode> nodes, Platform platform) {
299:                for (RegistryNode node : nodes) {
300:                    try {
301:                        if (node instanceof  Product) {
302:                            if (!((Product) node).getPlatforms().contains(
303:                                    platform)) {
304:                                continue;
305:                            }
306:                        }
307:
308:                        String icon = null;
309:                        String displayName = node.getDisplayName();
310:                        String treeHandle = null;
311:
312:                        if (node.getIconUri() == null) {
313:                            icon = "img/default-icon.png";
314:                        } else {
315:                            icon = node.getIconUri().getRemote().toString();
316:                        }
317:
318:                        if (node.getChildren().size() > 0) {
319:                            treeHandle = "img/tree-handle-open.png";
320:                        } else {
321:                            treeHandle = "img/tree-handle-empty.png";
322:                        }
323:
324:                        String id = null;
325:
326:                        String uid = node.getUid();
327:                        String version = null;
328:                        String type = null;
329:                        String platforms = null;
330:                        String title = "";
331:
332:                        if (node instanceof  Product) {
333:                            version = ((Product) node).getVersion().toString();
334:                            platforms = StringUtils.asString(((Product) node)
335:                                    .getPlatforms(), " ");
336:                            title = StringUtils.asString(((Product) node)
337:                                    .getPlatforms());
338:                            type = "component";
339:
340:                            id = registry + "_" + uid + "_" + version + "_"
341:                                    + platforms.replace(" ", "_") + "_" + type;
342:                        }
343:
344:                        if (node instanceof  Group) {
345:                            type = "group";
346:
347:                            id = registry + "_" + uid + "_" + type;
348:                        }
349:
350:                        out.println("                <tr id=\"" + id + "\">");
351:
352:                        out
353:                                .println("                    <td class=\"tree-handle\"><img src=\""
354:                                        + treeHandle
355:                                        + "\" onclick=\"_expand('"
356:                                        + id + "-children')\"/></td>");
357:                        out
358:                                .println("                    <td class=\"icon\"><img src=\""
359:                                        + icon + "\"/></td>");
360:                        out
361:                                .println("                    <td class=\"display-name\" title=\""
362:                                        + title + "\">" + displayName + "</td>");
363:                        if (node.getParent() != null) {
364:                            out
365:                                    .println("                    <td class=\"option\"><a href=\"javascript: remove_component('"
366:                                            + uid
367:                                            + "', '"
368:                                            + version
369:                                            + "', '"
370:                                            + platforms
371:                                            + "')\">Remove</a></td>");
372:                        } else {
373:                            out
374:                                    .println("                    <td class=\"option\"></td>");
375:                        }
376:                        out
377:                                .println("                    <td class=\"option\"><a href=\"javascript: add_package('"
378:                                        + uid
379:                                        + "', '"
380:                                        + version
381:                                        + "', '"
382:                                        + platforms
383:                                        + "')\">Add Package</a></td>");
384:
385:                        out.println("                </tr>");
386:
387:                        if (node.getChildren().size() > 0) {
388:                            out.println("                <tr id=\"" + id
389:                                    + "-children\">");
390:
391:                            out
392:                                    .println("                    <td class=\"tree-handle\"></td>");
393:                            out
394:                                    .println("                    <td colspan=\"4\" class=\"children\">");
395:                            out
396:                                    .println("                    <table class=\"registry\">");
397:                            buildRegistryNodes(out, registry, node
398:                                    .getChildren(), platform);
399:                            out.println("                    </table>");
400:                            out.println("                    </td>");
401:
402:                            out.println("                </tr>");
403:                        }
404:                    } catch (Throwable e) {
405:                        e.printStackTrace(out);
406:                    }
407:                }
408:            }
409:        }
www___._j_a_v__a_2__s___.__c___o__m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.