Source Code Cross Referenced for ViewXMLExportIssues.java in  » Issue-Tracking » scarab-0.21 » org » tigris » scarab » screens » admin » 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 » Issue Tracking » scarab 0.21 » org.tigris.scarab.screens.admin 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.tigris.scarab.screens.admin;
002:
003:        /* ================================================================
004:         * Copyright (c) 2000-2002 CollabNet.  All rights reserved.
005:         * 
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions are
008:         * met:
009:         * 
010:         * 1. Redistributions of source code must retain the above copyright
011:         * notice, this list of conditions and the following disclaimer.
012:         * 
013:         * 2. Redistributions in binary form must reproduce the above copyright
014:         * notice, this list of conditions and the following disclaimer in the
015:         * documentation and/or other materials provided with the distribution.
016:         * 
017:         * 3. The end-user documentation included with the redistribution, if
018:         * any, must include the following acknowlegement: "This product includes
019:         * software developed by Collab.Net <http://www.Collab.Net/>."
020:         * Alternately, this acknowlegement may appear in the software itself, if
021:         * and wherever such third-party acknowlegements normally appear.
022:         * 
023:         * 4. The hosted project names must not be used to endorse or promote
024:         * products derived from this software without prior written
025:         * permission. For written permission, please contact info@collab.net.
026:         * 
027:         * 5. Products derived from this software may not use the "Tigris" or 
028:         * "Scarab" names nor may "Tigris" or "Scarab" appear in their names without 
029:         * prior written permission of Collab.Net.
030:         * 
031:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
032:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
033:         * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
034:         * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
035:         * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
036:         * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
037:         * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
038:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
039:         * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
040:         * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
041:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
042:         *
043:         * ====================================================================
044:         * 
045:         * This software consists of voluntary contributions made by many
046:         * individuals on behalf of Collab.Net.
047:         */
048:
049:        // Jaav stuff
050:        import java.util.Iterator;
051:        import java.util.List;
052:        import java.util.ArrayList;
053:
054:        import org.apache.velocity.VelocityContext;
055:        import org.apache.fulcrum.velocity.TurbineVelocity;
056:        import org.apache.turbine.RunData;
057:        import org.apache.turbine.TemplateContext;
058:        import org.apache.turbine.Turbine;
059:        import org.tigris.scarab.actions.Search;
060:        import org.tigris.scarab.om.Module;
061:
062:        import org.tigris.scarab.tools.ScarabRequestTool;
063:        import org.tigris.scarab.tools.ScarabLocalizationTool;
064:        import org.tigris.scarab.screens.Default;
065:        import org.tigris.scarab.om.Issue;
066:        import org.tigris.scarab.om.IssueManager;
067:        import org.tigris.scarab.util.word.QueryResult;
068:        import org.tigris.scarab.util.xmlissues.ImportIssues;
069:
070:        /**
071:         * Sends XML Export issues contents directly to the output stream.
072:         *
073:         * @author <a href="mailto:jon@collab.net">Jon Scott Stevens</a>
074:         * @version $Id: ViewXMLExportIssues.java 9954 2005-11-07 03:10:49Z hair $
075:         */
076:        public class ViewXMLExportIssues extends Default {
077:            /**
078:             * builds up the context for display of variables on the page.
079:             */
080:            public void doBuildTemplate(RunData data, TemplateContext context)
081:                    throws Exception {
082:                super .doBuildTemplate(data, context);
083:
084:                // probably should use intake, but i'm being lazy for now cause
085:                // this is only three form variables and not worth the trouble...
086:                // [hair] it is actually very useful that data.getParameters() is used
087:                // because it means that the xml results can be fetched through a Http GET
088:                // as well as the normal POST.
089:                String filename = data.getParameters().getString("filename");
090:                if (filename == null || filename.length() == 0
091:                        || filename.indexOf('/') > 0
092:                        || filename.indexOf(':') > 0
093:                        || filename.indexOf(';') > 0) {
094:                    filename = "scarab-issues-export.xml";
095:                }
096:
097:                final ScarabRequestTool scarabR = getScarabRequestTool(context);
098:                final Module currentModule = scarabR.getCurrentModule();
099:                final ScarabLocalizationTool l10n = getLocalizationTool(context);
100:
101:                // new functionality allows query parameter to select which issues to print
102:                final String query = data.getParameters().getString("go");
103:                String ids = null;
104:                final List allIdList = new ArrayList();
105:                if (query != null) {
106:                    final StringBuffer sb = new StringBuffer();
107:                    final Search searchAction = new Search();
108:                    searchAction.doSelectquery(data, context);
109:                    final Iterator it = scarabR.getCurrentSearchResults();
110:                    while (it.hasNext()) {
111:                        final QueryResult issue = (QueryResult) it.next();
112:                        sb.append(issue.getIdPrefix() + issue.getIdCount());
113:                        allIdList.add(issue.getIdPrefix() + issue.getIdCount());
114:                        if (it.hasNext()) {
115:                            sb.append(',');
116:                        }
117:                    }
118:                    ids = sb.toString();
119:                } else {
120:                    // issues are defined manually
121:                    ids = data.getParameters().getString("exportissues");
122:                }
123:                context.put("exportissues", ids);
124:                if (ids == null || ids.length() == 0) {
125:                    data.setTarget("admin,XMLExportIssues.vm");
126:                    scarabR.setAlertMessage(l10n.get("EnterIssues"));
127:                    return;
128:                } else {
129:                    // manually specified ids we need parse & verify
130:                    if (allIdList.isEmpty()) {
131:                        try {
132:                            // FIXME! we need this method to return valid ids, if the range
133:                            // is thousands of issues, we cannot post verify the issues.
134:                            allIdList.addAll(Issue.parseIssueList(
135:                                    currentModule, ids));
136:                        } catch (Exception e) {
137:                            data.setTarget("admin,XMLExportIssues.vm");
138:                            scarabR.setAlertMessage(l10n.getMessage(e));
139:                            return;
140:                        }
141:                    }
142:                    final List issueIdList = new ArrayList();
143:                    final List badIdList = new ArrayList();
144:                    final Integer currentModuleId = currentModule.getModuleId();
145:                    final String defaultCode = currentModule.getCode();
146:                    for (Iterator itr = allIdList.iterator(); itr.hasNext();) {
147:                        final String tmp = (String) itr.next();
148:                        final Issue issue = IssueManager.getIssueById(tmp,
149:                                defaultCode);
150:                        // check that the issue is in the current module, don't allow
151:                        // exporting of issues other than those in the current
152:                        // module for security reasons
153:                        if (issue != null && !issue.getDeleted()) {
154:                            issueIdList.add(tmp);
155:                        } else {
156:                            badIdList.add(tmp);
157:                        }
158:                    }
159:                    if (issueIdList.isEmpty()) {
160:                        data.setTarget("admin,XMLExportIssues.vm");
161:                        scarabR.setAlertMessage(l10n
162:                                .get("NoValidIssuesCouldBeLocated"));
163:                        return;
164:                    } else if (!badIdList.isEmpty()) {
165:                        data.setTarget("admin,XMLExportIssues.vm");
166:                        scarabR.setAlertMessage(l10n.format(
167:                                "FollowingIssueIdsAreInvalid", badIdList
168:                                        .toString()));
169:                        return;
170:                    }
171:
172:                    String contentType;
173:                    String contentDisposition;
174:                    if ("1".equals(data.getParameters().getString(
175:                            "downloadtype"))) {
176:                        // To browser window.
177:                        contentType = "text/xml";
178:                        contentDisposition = "inline";
179:                    } else {
180:                        // Save to file.  Unforunately, not all browsers are
181:                        // created equal, and some fail to fully heed the
182:                        // Content-disposition header.  We hack around this by
183:                        // using a Content-type header which indicates binary
184:                        // data.
185:                        //contentType = "text/xml";
186:                        contentType = "application/octet-stream";
187:                        contentDisposition = "attachment";
188:                    }
189:                    data.getResponse().setContentType(contentType);
190:                    data.getParameters().add("content-type", contentType);
191:                    contentDisposition += "; filename=" + filename;
192:                    data.getParameters().add("content-dispostion",
193:                            contentDisposition);
194:                    data.getResponse().setHeader("Content-Disposition",
195:                            contentDisposition);
196:
197:                    context.put("issueIdList", issueIdList);
198:                    final VelocityContext vc = new VelocityContext();
199:                    for (Iterator keys = context.keySet().iterator(); keys
200:                            .hasNext();) {
201:                        final String key = (String) keys.next();
202:                        vc.put(key, context.get(key));
203:                    }
204:                    vc.put("dtdURI", ImportIssues.SYSTEM_DTD_URI);
205:
206:                    final String encoding = Turbine.getConfiguration()
207:                            .getString("scarab.dataexport.encoding");
208:                    if (encoding != null && !encoding.equals("")) {
209:                        TurbineVelocity.handleRequest(vc,
210:                                "macros/XMLExportIssuesMacro.vm", data
211:                                        .getResponse().getOutputStream(),
212:                                encoding, encoding);
213:                    } else {
214:                        TurbineVelocity.handleRequest(vc,
215:                                "macros/XMLExportIssuesMacro.vm", data
216:                                        .getResponse().getOutputStream());
217:                    }
218:
219:                    // we already sent the response, there is no target to render
220:                    data.setTarget(null);
221:                }
222:            }
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.