Example usage for org.springframework.core NestedIOException NestedIOException

List of usage examples for org.springframework.core NestedIOException NestedIOException

Introduction

In this page you can find the example usage for org.springframework.core NestedIOException NestedIOException.

Prototype

public NestedIOException(@Nullable String msg, @Nullable Throwable cause) 

Source Link

Document

Construct a NestedIOException with the specified detail message and nested exception.

Usage

From source file:grails.plugin.cache.web.filter.redis.GrailsDeserializer.java

public Object deserialize(InputStream inputStream) throws IOException {
    ObjectInputStream ois = new ObjectInputStream(inputStream) {
        @Override//from w  ww.  j a  va 2s  .c  om
        protected Class<?> resolveClass(ObjectStreamClass osc) throws IOException, ClassNotFoundException {
            try {
                return Thread.currentThread().getContextClassLoader().loadClass(osc.getName());
            } catch (Exception e) {
                return super.resolveClass(osc);
            }
        }
    };

    try {
        return ois.readObject();
    } catch (ClassNotFoundException e) {
        throw new NestedIOException("Failed to deserialize object type", e);
    }
}

From source file:com.javaetmoi.core.spring.vfs.Vfs2Resource.java

@Override
public URL getURL() throws IOException {
    try {//from  w  ww.  jav a  2s .  c  o  m
        return Vfs2Utils.getURL(this.resource);
    } catch (Exception ex) {
        throw new NestedIOException("Failed to obtain URL for file " + this.resource, ex);
    }
}

From source file:com.dianping.resource.io.VfsResource.java

@Override
public URL getURL() throws IOException {
    try {/*ww w  . ja  va2s .  c o  m*/
        return VfsUtils.getURL(this.resource);
    } catch (Exception ex) {
        throw new NestedIOException("Failed to obtain URL for file " + this.resource, ex);
    }
}

From source file:slina.mb.smb.SmbSessionImpl.java

@Override
public boolean remove(String path) throws IOException {
    try {//  www.j a  va 2 s.c o  m
        SmbFile file = new SmbFile(path, ntlmAuth);
        file.delete();
    } catch (SmbAuthException ex) {
        // handle authentication related issue here
        isOpen = false;
        throw new NestedIOException("Failed to remove resource " + path, ex);
    } catch (SmbException ex) {
        // any special SMB related exception handling
        throw new NestedIOException("Failed to remove resource " + path, ex);
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Successfully removed resource " + path);
    }
    return true;
}

From source file:com.javaetmoi.core.spring.vfs.Vfs2Resource.java

@Override
public URI getURI() throws IOException {
    try {//from w w  w .  j  av  a2  s  .c  o m
        return Vfs2Utils.getURI(this.resource);
    } catch (Exception ex) {
        throw new NestedIOException("Failed to obtain URI for " + this.resource, ex);
    }
}

From source file:com.dianping.resource.io.VfsResource.java

@Override
public URI getURI() throws IOException {
    try {/*from   w  w  w . ja v a  2 s. c  o m*/
        return VfsUtils.getURI(this.resource);
    } catch (Exception ex) {
        throw new NestedIOException("Failed to obtain URI for " + this.resource, ex);
    }
}

From source file:kr.co.skysoft.framework.dbms.ibatis.FwSqlMapClientFactoryBean.java

protected SqlMapClient buildSqlMapClient(Resource[] configLocations, Resource[] mappingLocations,
        Properties properties) throws IOException {

    if (ObjectUtils.isEmpty(configLocations)) {
        throw new IllegalArgumentException("At least 1 'configLocation' entry is required");
    }/*www.jav a2  s.  com*/

    SqlMapClient client = null;
    FwSqlMapConfigParser configParser = new FwSqlMapConfigParser();
    for (Resource configLocation : configLocations) {
        InputStream is = configLocation.getInputStream();
        try {
            client = configParser.parse(is, properties);
        } catch (RuntimeException ex) {
            //SqlMap? ?  ???? ?   ? ?  ?? 
            logger.error("##### Failed to parse config resource: " + configLocation, ex);
        }
    }

    if (mappingLocations != null) {
        SqlMapParser mapParser = SqlMapParserFactory.createSqlMapParser(configParser);
        for (Resource mappingLocation : mappingLocations) {
            try {
                mapParser.parse(mappingLocation.getInputStream());
            } catch (NodeletException ex) {
                throw new NestedIOException("Failed to parse mapping resource: " + mappingLocation, ex);
            }
        }
    }

    return client;
}

From source file:slina.mb.smb.SmbSessionImpl.java

public void read(String source, OutputStream os, long skipLimit) throws IOException {

    try {//from  www . j a  v a 2s.c o  m
        SmbFile file = new SmbFile(source, ntlmAuth);
        InputStream is = file.getInputStream();

        long remoteFileSize = file.length();

        if (remoteFileSize > skipLimit) {

            long skip = remoteFileSize - skipLimit;
            is.skip(skip);
        }
        FileCopyUtils.copy(is, os);
    } catch (SmbAuthException ex) {
        // handle authentication related issue here
        isOpen = false;
        throw new NestedIOException("Failed to read resource " + source, ex);
    } catch (SmbException ex) {
        // any special SMB related exception handling
        throw new NestedIOException("Failed to read resource " + source, ex);
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Successfully read resource " + source);
    }

}

From source file:slina.mb.smb.SmbSessionImpl.java

@Override
public void read(String source, OutputStream os) throws IOException {
    try {/*  ww w  .j  a  va  2s.  com*/
        SmbFile file = new SmbFile(source, ntlmAuth);
        InputStream is = file.getInputStream();

        long remoteFileSize = file.length();

        if (remoteFileSize > this.fileSizeLmit) {

            long skip = remoteFileSize - this.fileSizeLmit;
            is.skip(skip);

        }
        FileCopyUtils.copy(is, os);
    } catch (SmbAuthException ex) {
        // handle authentication related issue here
        isOpen = false;
        throw new NestedIOException("Failed to read resource " + source, ex);
    } catch (SmbException ex) {
        // any special SMB related exception handling
        throw new NestedIOException("Failed to read resource " + source, ex);
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Successfully read resource " + source);
    }
}

From source file:net.alpha.velocity.spring.web.VelocityLayoutView.java

/**
 * Overrides {@code VelocityView.checkTemplate()} to additionally check
 * that both the layout template and the screen content template can be loaded.
 * Note that during rendering of the screen content, the layout template
 * can be changed which may invalidate any early checking done here.
 *//*from   w  w  w .j  a v  a 2  s.  c  o  m*/
@Override
public boolean checkResource(Locale locale) throws Exception {
    if (!super.checkResource(locale)) {
        return false;
    }

    try {
        // Check that we can get the template, even if we might subsequently get it again.
        getTemplate(this.layoutUrl);
        return true;
    } catch (ResourceNotFoundException ex) {
        throw new NestedIOException("Cannot find Velocity template for URL [" + this.layoutUrl
                + "]: Did you specify the correct resource loader path?", ex);
    } catch (Exception ex) {
        throw new NestedIOException("Could not load Velocity template for URL [" + this.layoutUrl + "]", ex);
    }
}