View Javadoc

1   /*$Id: RawPipeResults.java,v 1.2 2005/03/21 18:45:55 mch Exp $
2    * Created on 13-Nov-2003
3    *
4    * Copyright (C) AstroGrid. All rights reserved.
5    *
6    * This software is published under the terms of the AstroGrid
7    * Software License version 1.2, a copy of which has been included
8    * with this distribution in the LICENSE.txt file.
9    *
10  **/
11  package org.astrogrid.dataservice.queriers;
12  
13  import java.io.IOException;
14  import java.io.InputStream;
15  import java.io.OutputStream;
16  import java.security.Principal;
17  import org.astrogrid.dataservice.queriers.QueryResults;
18  import org.astrogrid.dataservice.queriers.status.QuerierStatus;
19  import org.astrogrid.io.Piper;
20  import org.astrogrid.query.returns.ReturnSpec;
21  import org.astrogrid.slinger.targets.TargetIdentifier;
22  import org.astrogrid.tableserver.out.TableWriter;
23  
24  /***
25   * Pipes results as-they-are from the given inputstream to the target.
26   * If you are confident that the results are already in the right form suitable
27   * for delivering to the client, and you have an inputstream to them, this
28   * is the appropriate results wrapper to use.  For example, if you are proxying
29   * to a service that provides results in the right form, there's no point in
30   * interpreting them here.  Of course it woulld be nice to send them direct if
31   * possible, rather than routing them through here, but some stateless services
32   * can't do this.
33   *
34   */
35  public class RawPipeResults implements QueryResults {
36     
37     protected final InputStream in;
38     protected final String mimeType;
39     protected final Querier querier;
40     
41      /***  Std Constructor. xmlIn is a stream containing the xml document
42       */
43      public RawPipeResults(Querier aQuerier, InputStream source, String sourceMimeType) {
44        this.querier = aQuerier;
45        this.in = source;
46        this.mimeType = sourceMimeType;
47      }
48  
49      /***
50       * Sends as is - pipes out.  Mo status info yet...
51       */
52      public void send(ReturnSpec returnSpec, Principal user) throws IOException {
53         
54         TargetIdentifier target = returnSpec.getTarget();
55         
56         if (mimeType != null) {
57            target.setMimeType(mimeType, user);
58         }
59         OutputStream out = target.resolveOutputStream(user);
60  
61         Piper.bufferedPipe(in, out);
62      }
63      
64      /***
65       * Don't know how to write this out in table form...
66       */
67     public void writeTable(TableWriter tableWriter, QuerierStatus statusToUpdate) throws IOException {
68         throw new UnsupportedOperationException("Can't write Xml out to tables...");
69     }
70     
71  
72      
73  }
74  
75  
76  /*
77  $Log: RawPipeResults.java,v $
78  Revision 1.2  2005/03/21 18:45:55  mch
79  Naughty big lump of changes
80  
81  Revision 1.1.1.1  2005/02/17 18:37:35  mch
82  Initial checkin
83  
84  Revision 1.1.1.1  2005/02/16 17:11:24  mch
85  Initial checkin
86  
87  Revision 1.1.2.1  2004/12/08 18:36:40  mch
88  Added Vizier, rationalised SqlWriters etc, separated out TableResults from QueryResults
89  
90  Revision 1.2.24.3  2004/11/30 01:04:02  mch
91  Rationalised tablewriters, reverted AxisDataService06 to string
92  
93  Revision 1.2.24.2  2004/11/22 00:57:16  mch
94  New interfaces for SIAP etc and new slinger package
95  
96  Revision 1.2.24.1  2004/11/17 17:56:07  mch
97  set mime type, switched results to taking targets
98  
99  Revision 1.2  2004/10/18 13:11:30  mch
100 Lumpy Merge
101 
102 Revision 1.1.2.1  2004/10/15 19:59:06  mch
103 Lots of changes during trip to CDS to improve int test pass rate
104 
105 Revision 1.2  2004/09/29 18:43:51  mch
106 doc change
107 
108 Revision 1.1  2004/09/28 15:02:13  mch
109 Merged PAL and server packages
110 
111 Revision 1.1  2004/09/07 00:54:20  mch
112 Tidied up Querier/Plugin/Results, and removed deprecated SPI-visitor-SQL-translator
113 
114 Revision 1.1  2004/09/06 21:37:26  mch
115 Factored out VotableResults
116 
117 Revision 1.3  2004/09/01 12:10:58  mch
118 added results.toHtml
119 
120 Revision 1.2  2004/03/14 03:04:57  mch
121 Added CSV writer
122 
123 Revision 1.1  2004/03/13 23:40:59  mch
124 Changes to adapt to It05 refactor
125 
126 Revision 1.2  2003/12/09 16:25:08  nw
127 wrote plugin documentation
128 
129 Revision 1.1  2003/11/18 11:23:49  nw
130 mavenized cds delegate
131 
132 Revision 1.1  2003/11/18 11:10:05  nw
133 mavenized cds delegate
134  
135 */