Package com.volantis.map.sti.transcoder

Examples of com.volantis.map.sti.transcoder.TranscoderException


        // ==================================================================
        // Prepare expectations.
        // ==================================================================
        transcoderMock
            .expects.transcode(resourceDescriptorMock, httpServletRequestMock, httpServletResponseMock)
            .fails(new TranscoderException(null));

        // ==================================================================
        // Do the test.
        // ==================================================================
        try {
View Full Code Here


            SOAPEnvelope responseEnvelope = responseMessage.getSOAPPart().getEnvelope();
            SOAPBody responseBody = responseEnvelope.getBody();

            if (responseBody.hasFault()) {
                final SOAPFault fault = responseBody.getFault();
                throw new TranscoderException("soap-response-with-fault",
                        new Object[] { fault.getFaultCodeAsName(), fault.getFaultString() },
                        null);

            }
           
            document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();

            Node node = responseBody.getFirstChild();
            node = document.importNode(node, true);
            document.appendChild(node);

            // Create TranscodingResponse
            TranscodingResponse transcodingResponse = dom2TransRespConverter.convert(document);

            if (!transcodingRequest.getOperationID().equals(
                    transcodingResponse.getOperationID())) {
                LOGGER.warn("invalid-operationID", new Object[] {
                        transcodingResponse.getOperationID(),
                        transcodingRequest.getOperationID()});
            }

            String contentID = transcodingResponse.getJobResult(0).getOutput().getLocation();

            Iterator iterator = responseMessage.getAttachments();

            // Copy the content of the first attachement to the HTTP response stream.
            boolean foundAttachement = false;

            while (!foundAttachement && iterator.hasNext()) {
                AttachmentPart part = (AttachmentPart) iterator.next();

//                    if (part.getContentId().equals(contentID)) {
                foundAttachement = true;

                InputStream inputStream = part.getDataHandler().getInputStream();

                if (inputStream == null) {
                    throw new TranscoderException(null);
                }

                OutputStream outputStream = response.getOutputStream();

                response.setContentType(part.getContentType());
                response.setContentLength(part.getSize());
                // Copy the content of input inputStream to the output inputStream.
                // The exception loggin is set to debug level
                // because of vbm 2008030721 the browser requests the map resource
                // two times in a row and aborts the firts request most of the times

                try {
                    byte buf[] = new byte[1024];
                    int len;
                    while ((len = inputStream.read(buf)) != -1) {
                        outputStream.write(buf, 0, len);
                    }
                    outputStream.flush();
                } finally {
                    // Ensure we close the input.
                    try {
                        inputStream.close();
                    } catch (IOException e) {
                        if (LOGGER.isDebugEnabled()) {
                            LOGGER.debug(e);
                        }
                    }
                    // Ensure we close the output.
                    try {
                        outputStream.close();
                    } catch (IOException e) {
                        if (LOGGER.isDebugEnabled()) {
                            LOGGER.debug(e);
                        }
                    }
                }
            }
        } catch (SOAPException e) {
            throw new TranscoderException(e);
        } catch (ConverterException e) {
            throw new TranscoderException(e);
        } catch (ParserConfigurationException e) {
            throw new TranscoderException(e);
        } catch (IOException e) {
            throw new TranscoderException(e);
        } catch (MimeTypeRetrieverException e) {
            throw new TranscoderException(e);
        }       
    }
View Full Code Here

TOP

Related Classes of com.volantis.map.sti.transcoder.TranscoderException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.