/** * @return if the storage location was set, this method will return the web url of the stored output file. * <code>Null</code> otherwise. */ public String getWebURL() { return location != null ? location.getWebURL() : null; } }
OutputStorage( File file, String id, String mimeType ) throws IOException { super( file, id, mimeType ); storeMimeType(); }
OutputStorage( File file, String id ) throws IOException { super( file, id, null ); this.mimeType = retrieveMimeType(); }
public void sendResource ( HttpResponseBuffer response) { try { response.setContentType( getMimeType() ); response.setContentLength( (int) getLength() ); OutputStream os = response.getOutputStream(); InputStream is = getInputStream(); byte[] buffer = new byte[4096]; int numBytes = -1; while ( ( numBytes = is.read( buffer ) ) != -1 ) { os.write( buffer, 0, numBytes ); } os.flush(); } catch ( IOException e ) { LOG.debug( "Error sending resource to client.", e ); } }
LOG.debug( "Checking if a process corresponding to output '" + location.getId() + "' is known (=still running)." ); if ( status == null ) { LOG.debug( "No. Trying to return the stored response document." ); if ( location.getFile().exists() ) { location.sendResource( response ); } else { try { response.sendError( 404, "No stored (or pending) WPS response document with id '" + location.getId() + "' found." ); } catch ( IOException e1 ) {
public synchronized OutputStorage newOutputStorage( String mimeType ) throws IOException { LOG.debug( "Allocating new storage location for publishing output parameter." ); String outputId = generateOutputId(); String resourceName = OUTPUT_PREFIX + outputId; File resourceFile = new File( baseDir, resourceName ); if ( resourceFile.exists() ) { LOG.debug( "File '" + resourceFile + "' already exists. Deleting it." ); resourceFile.delete(); } return new OutputStorage( resourceFile, outputId, mimeType ); }
public ResponseDocumentStorage newResponseDocumentStorage( String getUrl ) { LOG.debug( "Allocating new storage location for publishing response document." ); String responseId = generateResponseId(); String resourceName = RESPONSE_PREFIX + responseId; File resourceFile = new File( baseDir, resourceName ); if ( resourceFile.exists() ) { LOG.debug( "File '" + resourceFile + "' already exists. Deleting it." ); resourceFile.delete(); } return new ResponseDocumentStorage( resourceFile, responseId, getUrl ); }
private void doGetOutput( String storedOutputId, HttpResponseBuffer response ) { LOG.trace( "doGetOutput invoked, requested stored output: " + storedOutputId ); OutputStorage resource = storageManager.lookupOutputStorage( storedOutputId ); if ( resource == null ) { try { response.sendError( 404, "No stored output with id '" + storedOutputId + "' found." ); } catch ( IOException e ) { LOG.debug( "Error sending exception report to client.", e ); } } else { resource.sendResource( response ); } LOG.trace( "doGetOutput finished" ); }
public ResponseDocumentStorage lookupResponseDocumentStorage( String responseId, String getUrl ) { File resourceFile = new File( baseDir, RESPONSE_PREFIX + responseId ); return new ResponseDocumentStorage( resourceFile, responseId, getUrl ); }
/** * Construct a complex output, values will be written to the location and probably not stored. * * @param outputType * @param location * @param isRequested * @param requestedMimeType * @param requestedSchema * @param requestedEncoding * @throws FileNotFoundException * @throws XMLStreamException */ public ComplexOutputImpl( ComplexOutputDefinition outputType, OutputStorage location, boolean isRequested, String requestedMimeType, String requestedSchema, String requestedEncoding ) throws FileNotFoundException, XMLStreamException { super( outputType, isRequested ); LOG.debug( "Creating sink for complex output at location '" + location + "'" ); this.location = location; os = location.getOutputStream(); this.requestedMimeType = requestedMimeType; this.requestedSchema = requestedSchema; this.requestedEncoding = requestedEncoding; }
public OutputStorage lookupOutputStorage( String outputId ) { OutputStorage output = null; File resourceFile = new File( baseDir, OUTPUT_PREFIX + outputId ); try { if ( resourceFile.exists() ) { output = new OutputStorage( resourceFile, outputId ); } } catch ( IOException e ) { LOG.debug( "Cannot access stored output (file='" + resourceFile + "')" ); } return output; }
public synchronized StreamBufferStore newInputSink() { LOG.debug( "Allocating new sink for temporarily storing complex input parameter." ); String outputId = generateInputId(); String resourceName = INPUT_PREFIX + outputId; File resourceFile = new File( baseDir, resourceName ); if ( resourceFile.exists() ) { LOG.debug( "File '" + resourceFile + "' already exists. Deleting it." ); resourceFile.delete(); } return new StreamBufferStore( inputDiskSwitchLimit, resourceFile ); }
private void doGetResponseDocument( String responseId, HttpResponseBuffer response ) { LOG.trace( "doGetResponseDocument invoked, requested stored response document: " + responseId ); ResponseDocumentStorage resource = storageManager.lookupResponseDocumentStorage( responseId, getHttpGetURL() ); executeHandler.sendResponseDocument( response, resource ); LOG.trace( "doGetResponseDocument finished" ); }
/** * Closes the stream writer and writes the end document (if it was initialized). * * @throws XMLStreamException * @throws IOException */ public void close() throws XMLStreamException, IOException { if ( streamWriter != null ) { LOG.debug( "Closing sink for xml output at location '" + location + "'" ); streamWriter.writeEndDocument(); streamWriter.flush(); streamWriter.close(); if ( location != null ) { streamReader = inputFactory.createXMLStreamReader( new BufferedInputStream( location.getInputStream() ) ); } } else { if ( location != null ) { LOG.debug( "Closing sink for raw output at location '" + location + "'" ); os.flush(); os.close(); is = new BufferedInputStream( location.getInputStream() ); } } }
factory.setProperty( "javax.xml.stream.isRepairingNamespaces", Boolean.TRUE ); XMLStreamWriter writer = factory.createXMLStreamWriter( new OutputStreamWriter( responseStorage.getOutputStream(), "UTF-8" ) ); ExecuteResponseXMLWriter.export100( writer, executeResponse );
writer.writeAttribute( "statusLocation", "" + response.getStatusLocation().getWebURL() );
/** * Creates a {@link ProcessletOutput} parameter object for storing a requested process output value. * * @param outputDef * @return object for storing the corresponding process output value */ private ProcessletOutput createOutputParameter( RequestedOutput outputDef ) throws OWSException { ProcessletOutput processOutput = null; ProcessletOutputDefinition outputType = outputDef.getOutputType(); if ( outputType instanceof BoundingBoxOutputDefinition ) { processOutput = new BoundingBoxOutputImpl( (BoundingBoxOutputDefinition) outputType, true ); } else if ( outputType instanceof LiteralOutputDefinition ) { processOutput = new LiteralOutputImpl( (LiteralOutputDefinition) outputType, outputDef.getUom(), true ); } else if ( outputType instanceof ComplexOutputDefinition ) { try { String requestedMimeType = outputDef.getMimeType(); String requestedEncoding = outputDef.getEncoding(); String requestedSchema = outputDef.getSchemaURL(); processOutput = new ComplexOutputImpl( (ComplexOutputDefinition) outputType, storageManager.newOutputStorage( requestedMimeType ), true, requestedMimeType, requestedSchema, requestedEncoding ); } catch ( Exception e ) { String msg = "Unable to create sink for complex output parameter: " + e.getMessage(); LOG.error( msg, e ); throw new OWSException( msg, NO_APPLICABLE_CODE ); } } return processOutput; }
StreamBufferStore store = storageManager.newInputSink(); LOG.debug( "Storing embedded ComplexInput as XML" ); XMLStreamReader xmlReader = complexDataElement.getXMLStreamReaderWithoutCaching();
throw new ResourceInitException( msg ); storageManager = new StorageManager( storageDir, inputDiskSwitchLimit );
responseStorage = storageManager.newResponseDocumentStorage( OGCFrontController.getHttpGetURL() );