List of usage examples for org.springframework.core NestedIOException NestedIOException
public NestedIOException(String msg)
From source file:slina.mb.smb.SmbSessionImpl.java
@Override public SmbFile[] list(String path) throws IOException { try {/*from ww w.j av a 2 s . co m*/ SmbFile file = new SmbFile(path, ntlmAuth); SmbFile[] list = file.listFiles(); if (list == null) { throw new NestedIOException("Failed to list resource - unable to resolve " + path); } return list; } catch (SmbAuthException ex) { // handle authentication related issue here isOpen = false; throw new NestedIOException("Failed to list resource " + path, ex); } catch (SmbException ex) { // any special SMB related exception handling throw new NestedIOException("Failed to list resource " + path, ex); } }
From source file:org.springframework.integration.sftp.session.SftpSession.java
public boolean remove(String path) throws IOException { Assert.state(this.channel != null, "session is not connected"); try {/*w w w. j av a 2 s.co m*/ this.channel.rm(path); return true; } catch (SftpException e) { throw new NestedIOException("Failed to remove file: " + e); } }
From source file:org.springframework.integration.smb.session.SmbSession.java
/** * Returns the contents of the specified SMB resource as an array of SmbFile objects. * In case the remote resource does not exist, an empty array is returned. * @param _path path to a remote directory * @return array of SmbFile objects/* w w w .j a v a2 s . co m*/ * @throws IOException on error conditions returned by a CIFS server or if the remote resource is not a directory. * @see org.springframework.integration.file.remote.session.Session#list(java.lang.String) */ public SmbFile[] list(String _path) throws IOException { SmbFile[] files = new SmbFile[0]; try { SmbFile smbDir = createSmbDirectoryObject(_path); if (!smbDir.exists()) { logger.warn("Remote directory [" + _path + "] does not exist. Cannot list resources."); return files; } else if (!smbDir.isDirectory()) { throw new NestedIOException("Resource [" + _path + "] is not a directory. Cannot list resources."); } files = smbDir.listFiles(); } catch (SmbException _ex) { throw new NestedIOException("Failed to list resources in [" + _path + "].", _ex); } String msg = "Successfully listed " + files.length + " resource(s) in [" + _path + "]"; if (logger.isDebugEnabled()) { logger.debug(msg + ": " + Arrays.toString(files)); } else { logger.info(msg + "."); } return files; }
From source file:org.springframework.integration.smb.session.SmbSession.java
/** * Reads the remote resource specified by path and copies its contents to the specified * {@link OutputStream}.// ww w .ja v a2s . com * @param _path path to a remote file * @param _outputStream output stream * @throws IOException on error conditions returned by a CIFS server or if the remote resource is not a file. * @see org.springframework.integration.file.remote.session.Session#read(java.lang.String, java.io.OutputStream) */ public void read(String _path, OutputStream _outputStream) throws IOException { Assert.hasText(_path, "path must not be empty"); Assert.notNull(_outputStream, "outputStream must not be null"); try { SmbFile remoteFile = createSmbFileObject(_path); if (!remoteFile.isFile()) { throw new NestedIOException("Resource [" + _path + "] is not a file."); } FileCopyUtils.copy(remoteFile.getInputStream(), _outputStream); } catch (SmbException _ex) { throw new NestedIOException("Failed to read resource [" + _path + "].", _ex); } logger.info("Successfully read resource [" + _path + "]."); }