Source Code Cross Referenced for LabelBureauFrame.java in  » Web-Server » Jigsaw » org » w3c » jigsaw » pics » 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 » Web Server » Jigsaw » org.w3c.jigsaw.pics 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // LabelBureauFrame.java
002:        // $Id: LabelBureauFrame.java,v 1.6 2000/08/16 21:37:43 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1998.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.jigsaw.pics;
007:
008:        import org.w3c.tools.resources.FramedResource;
009:        import org.w3c.tools.resources.ProtocolException;
010:
011:        import org.w3c.www.http.HTTP;
012:
013:        import org.w3c.jigsaw.http.HTTPException;
014:        import org.w3c.jigsaw.http.Reply;
015:        import org.w3c.jigsaw.http.Request;
016:
017:        import org.w3c.jigsaw.forms.URLDecoder;
018:        import org.w3c.jigsaw.forms.URLDecoderException;
019:
020:        import org.w3c.jigsaw.frames.HTTPFrame;
021:        import org.w3c.jigsaw.frames.PostableFrame;
022:
023:        /**
024:         * @version $Revision: 1.6 $
025:         * @author  Benoît Mahé (bmahe@w3.org)
026:         */
027:        public class LabelBureauFrame extends PostableFrame {
028:
029:            protected LabelBureauResource labelb = null;
030:
031:            /**
032:             * Register our resource. Must be an instance of ServletWrapper.
033:             */
034:            public void registerResource(FramedResource resource) {
035:                super .registerOtherResource(resource);
036:                if (resource instanceof  LabelBureauResource)
037:                    labelb = (LabelBureauResource) resource;
038:            }
039:
040:            /**
041:             * Parse the URLs given in the URLDecoder, as the <strong>u</strong> field.
042:             * This method just unquote any quoted URLs, before sending them back.
043:             * @param data The URLDecoder to get data from.
044:             * @return An array of String, properly parsed.
045:             */
046:
047:            protected String[] parseURLs(String us[]) {
048:                //FIXME .... no FIX IE!
049:                if (us[0] == null)
050:                    return null;
051:                String urls[] = new String[us.length];
052:                for (int i = 0; i < us.length; i++) {
053:                    if (us[i].charAt(0) == '"') {
054:                        int ulen = us[i].length();
055:                        // unquote only if last char is a quote, otherwise, leave as is
056:                        // which will trigger an exception when trying to build the URL
057:                        // object out of it.
058:                        if (us[i].charAt(ulen - 1) == '"')
059:                            urls[i] = us[i].substring(1, ulen - 1);
060:                    } else {
061:                        urls[i] = us[i];
062:                    }
063:                }
064:                return urls;
065:            }
066:
067:            /**
068:             * Get the integer code for the String based PICS format.
069:             * @param request The request to be handled.
070:             * @param format The string representation of the format.
071:             * @return An LabelBureauInterface defined format code.
072:             * @exception HTTPException if processing the request failed.
073:             * @see org.w3c.jigsaw.pics.LabelBureauInterface
074:             */
075:
076:            protected int parseFormat(Request request, String format)
077:                    throws HTTPException {
078:                if (format == null) {
079:                    return LabelBureauInterface.FMT_FULL;
080:                } else if (format.equals("minimal")) {
081:                    return LabelBureauInterface.FMT_MINIMAL;
082:                } else if (format.equals("short")) {
083:                    return LabelBureauInterface.FMT_SHORT;
084:                } else if (format.equals("full")) {
085:                    return LabelBureauInterface.FMT_FULL;
086:                } else if (format.equals("signed")) {
087:                    return LabelBureauInterface.FMT_SIGNED;
088:                }
089:                Reply error = request.makeReply(HTTP.BAD_REQUEST);
090:                error.setContent("Unknown label format: " + format);
091:                throw new HTTPException(error);
092:            }
093:
094:            /**
095:             * Handle the request.
096:             * @param request The request to be handled.
097:             * @param data The URLDecoder
098:             * @return A Reply instance.
099:             * @exception ProtocolException if processing the request failed.
100:             * @see org.w3c.jigsaw.pics.LabelBureauInterface
101:             */
102:            public Reply handle(Request request, URLDecoder data)
103:                    throws ProtocolException {
104:                if (labelb == null) {
105:                    Reply reply = request.makeReply(HTTP.INTERNAL_SERVER_ERROR);
106:                    reply
107:                            .setContent("LabelBureauFrame not configured properly: "
108:                                    + "must be attached to a LabelBureauResource.");
109:                    throw new HTTPException(reply);
110:                }
111:                // Get opt (only generic/normal/insert)
112:                String opt = data.getValue("opt");
113:                String urls[] = parseURLs(data.getMultipleValues("u"));
114:                int iformat = parseFormat(request, data.getValue("format"));
115:                String services[] = parseURLs(data.getMultipleValues("s"));
116:                if (services == null)
117:                    services = labelb.getServices();
118:                if ((services == null) || (services.length == 0))
119:                    return labelb.makePICSErrorReply(request,
120:                            "no-ratings \"unknown service\"");
121:                // Perform request
122:                if (labelb.getDebugFlag()) {
123:                    System.out.println("******** PICS REQUEST ********");
124:                    System.out.println("opt      : " + opt);
125:                    System.out.println("format   : " + data.getValue("format"));
126:                    System.out.print("services : ");
127:                    for (int i = 0; i < services.length; i++)
128:                        System.out.println(services[i]);
129:                    System.out.print("urls     : ");
130:                    for (int i = 0; i < urls.length; i++)
131:                        System.out.println(urls[i]);
132:                    System.out.println("******************************");
133:                }
134:                if (opt.equals("generic")) {
135:                    return labelb.getGenericLabels(request, iformat, urls,
136:                            services, data);
137:                } else if (opt.equals("normal")) {
138:                    return labelb.getNormalLabels(request, iformat, urls,
139:                            services, data);
140:                } else if (opt.equals("tree")) {
141:                    return labelb.getTreeLabels(request, iformat, urls,
142:                            services, data);
143:                } else if (opt.equals("generic+tree")) {
144:                    return labelb.getGenericTreeLabels(request, iformat, urls,
145:                            services, data);
146:                } else {
147:                    Reply error = request.makeReply(HTTP.BAD_REQUEST);
148:                    error.setContent("Invalid label bureau query, bad option: "
149:                            + opt);
150:                    throw new HTTPException(error);
151:                }
152:            }
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.