Package org.jboss.soa.esb.couriers

Examples of org.jboss.soa.esb.couriers.CourierException


                        if (handler instanceof LocalFileHandler)
                        {
                                _localFhandler = (LocalFileHandler) handler;
                                File file = new File(_uri);
                                if ((!_receiverOnly) && (!file.isDirectory()))
                                        throw new CourierException(
                                                        "File for deliverAsync EPR must be a directory (file name will be MessageID)");

                                File directory = (file.isDirectory()) ? file : file
                                                .getParentFile();
                                if (null==directory)
                                        directory = new File("");
                                if (!directory.canRead())
                                        throw new CourierException("Can't read directory "
                                                        + directory.toString());
                                // need to write even if it's readOnly - file will be renamed
                                // during xfer
                                if (!directory.canWrite())
                                        throw new CourierException("Can't write in directory "
                                                        + directory.toString());

                                return;
                        }
                }
View Full Code Here


         *             if problems were encountered
         */
        public boolean deliver(Message message) throws CourierException, MalformedEPRException
        {
                if (_receiverOnly)
                        throw new CourierException("This is a pickUp-only Courier");

                if (null == message)
                        return false;

                // FileHandler is durable only for local filesystem (see
                // checkEprParms())
                FileHandler handler = (null != _localFhandler) ? _localFhandler
                                : FileHandlerFactory.getInstance().getFileHandler(_epr);
                if (null == handler)
                        throw new CourierServiceBindException(
                                        "Can't find appropriate file handler for "
                                                        + _uri.toASCIIString());

                Call call = message.getHeader().getCall();
                if (null==call)
                        message.getHeader().setCall(call=new Call());
                try
                {
                        if (null==call.getMessageID())
                                call.setMessageID(new URI(UUID.randomUUID().toString()));
                }
                catch (URISyntaxException e)
                {
                        throw new MalformedEPRException("Problems with message header ",e);
                }
               
                File tmpFile = null;

                if (handler instanceof LocalFileHandler)
                {
                        try
                        {
                                File dir = new File(_uri);
                                String name = message.getHeader().getCall().getMessageID()
                                                .toString();
                                name += _inputSuffix;
       
                                tmpFile = CourierUtil.messageToLocalFile(dir, message);

                                handler.renameFile(tmpFile, new File(dir, name));

                                return true;
                        }
                        catch (final CourierException e)
                        {
                            throw new CourierTransportException(e);
                        }
                        catch (final IOException e)
                        {
                                throw new CourierMarshalUnmarshalException(e);
                        }
                        catch (final ParserConfigurationException e// it's no longer thrown so we can ignore it!
                        {
                                throw new CourierException(e);
                        }
                }

                tmpFile = null;
               
                try
                {
                        Method upload = handler.getClass().getMethod("uploadFile",
                                        new Class[]
                                        { File.class });

                        String sDir = FtpUtils.getLocalDir();
                        File dir = new File(sDir);
                        String name = message.getHeader().getCall().getMessageID().toString();
                       
                        name += _inputSuffix;
                       
                        tmpFile = CourierUtil.messageToLocalFile(dir, message);

                        File messageFile = new File(dir, name);
                        FileUtil.renameTo(tmpFile, messageFile);
                        tmpFile = messageFile;

                        upload.invoke(handler, new Object[]
                        { messageFile });
                        return true;
                }
                catch (final IOException ex)
                {
                    throw new CourierMarshalUnmarshalException(ex);
                }
                catch (final Exception e)
                {
                        throw new CourierException(e);
                }
                finally
                {
                        if ((null != tmpFile) && !tmpFile.delete() && _logger.isDebugEnabled())
                        {
View Full Code Here

                        {
                            throw ex;
                        }
                        catch (final Exception ex)
                        {
                                throw new CourierException(ex);
                        }
                }

                File tmpFile = null;
                try
View Full Code Here

                        out.close();
                        return out.toByteArray();
                }
                catch (FileNotFoundException e)
                {
                        throw new CourierException(e);
                }
                catch (IOException e)
                {
                        throw new CourierException(e);
                }
                catch (Exception e)
                {
                        throw new CourierException(e);
                }
        }
View Full Code Here

        {
                try
                {
                        File dir = new File(_epr.getURI());
                        if (!dir.isDirectory())
                                throw new CourierException(
                                                "Can't get file list if URL is not a directory");

                        FileFilter filter = new FileEndsWith(_epr.getInputSuffix());
                        return dir.listFiles(filter);
                }
                catch (Exception e)
                {
                        throw new CourierException(e);
                }
        }
View Full Code Here

        public boolean renameFile(File from, File to) throws CourierException
        {
                try
                {
                        if (to.exists() && !to.delete())
                            throw new CourierException("Unable to delete target file " + to.getCanonicalPath());
                        if (!FileUtil.renameTo(from, to))
                                throw new CourierException("Unable to rename from " + from
                                                + " to " + to);
                       
                        return true;
                }
                catch (Exception e)
                {
                        throw new CourierException(e);
                }
        }
View Full Code Here

                FileEndsWith(String p_sEnd) throws CourierException
                {
                        m_sSuffix = p_sEnd;
                        if (Util.isNullString(m_sSuffix))
                                throw new CourierException(
                                                "A file suffix (or full Message id) must be specified for pickup");
                } // ______________________________
View Full Code Here

                {
                        uri = _epr.getURI();
                }
                catch (URISyntaxException e)
                {
                        throw new CourierException(e);
                }

                _server = uri.getHost();

                String[] sa = null;
View Full Code Here

                }
                catch (Exception e)
                {
                        e.printStackTrace();
                       
                        throw new CourierException(e);
                }
                finally
                {
                    handler.quit() ;
                }
View Full Code Here

                catch (Exception e)
                {
                        // TODO better error handling, e.g., what if someone
                        // tries to download a directory?
                       
                        throw new CourierException(e);
                }
        }
View Full Code Here

TOP

Related Classes of org.jboss.soa.esb.couriers.CourierException

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.