Example usage for java.io IOException getClass

List of usage examples for java.io IOException getClass

Introduction

In this page you can find the example usage for java.io IOException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.constellio.app.modules.es.connectors.smb.security.WindowsPermissions.java

protected void processSharePermissions(SmbFile file) {
    ACE[] shareAces = null;//w  w  w  . j  a  v  a  2 s .  com
    for (int tries = 5; tries >= 0; tries--) {
        try {
            shareAces = file.getShareSecurity(true);
            // Success, exit try-loop
            break;
        } catch (IOException ioe) {
            if (tries == 0) {
                LOG.warning("Exception (SHARE PERMISSIONS)) : " + file.getCanonicalPath() + " ("
                        + ioe.getClass().getCanonicalName() + ": " + ioe.getMessage());
                errors.add("Exception (SHARE PERMISSIONS) :" + ioe.getMessage());
            }
        }
    }
    updateACE(shareAces, allowTokenShare, denyTokenShare);
}

From source file:com.constellio.app.modules.es.connectors.smb.security.WindowsPermissions.java

protected boolean processNTFSPermissions(SmbFile file) {
    ACE[] documentAces = null;/*from   w w w  . ja  v a  2s .  com*/
    for (int tries = 5; tries >= 0; tries--) {
        try {
            documentAces = file.getSecurity(true);
            break;
        } catch (IOException ioe) {
            if (tries == 0) {
                LOG.warning("Exception (NTFS PERMISSIONS)) : " + file.getCanonicalPath() + " ("
                        + ioe.getClass().getCanonicalName() + ": " + ioe.getMessage());
                errors.add("Exception (NTFS PERMISSIONS) :" + ioe.getMessage());
            }
        }
    }
    updateACE(documentAces, allowTokenDocument, denyTokenDocument);
    if (documentAces != null) {
        return true;
    } else {
        return false;
    }
}

From source file:org.jwebsocket.plugins.flashbridge.FlashBridgePlugIn.java

private void mGetSettings() {
    // load global settings, default to "true"
    String lPathToCrossDomainXML = getString(PATH_TO_CROSSDOMAIN_XML);
    if (lPathToCrossDomainXML != null) {
        try {//from  ww  w .  j ava2  s . c om
            if (mLog.isDebugEnabled()) {
                mLog.debug("Trying to load " + lPathToCrossDomainXML + "...");
            }
            lPathToCrossDomainXML = JWebSocketConfig.expandEnvVarsAndProps(lPathToCrossDomainXML);
            if (mLog.isDebugEnabled()) {
                mLog.debug("Trying to load expanded " + lPathToCrossDomainXML + "...");
            }
            URL lURL = JWebSocketConfig.getURLFromPath(lPathToCrossDomainXML);
            if (mLog.isDebugEnabled()) {
                mLog.debug("Trying to load from URL " + lURL + "...");
            }
            File lFile = new File(lURL.getPath());
            mCrossDomainXML = FileUtils.readFileToString(lFile, "UTF-8");
            if (mLog.isInfoEnabled()) {
                mLog.info("crossdomain config successfully loaded from " + lPathToCrossDomainXML + ".");
            }
        } catch (IOException lEx) {
            mLog.error(lEx.getClass().getSimpleName() + " reading crossdomain.xml: " + lEx.getMessage());
        }
    }
    String lPort = getString(PORT_CONFIGURATION);
    if (lPort != null) {
        try {
            // Checking if there is any port defined in the configuration
            Integer lInPort = Integer.parseInt(lPort.trim());
            if (lInPort > 0) {
                mListenerPort = lInPort;
            }
        } catch (NumberFormatException e) {
            mLog.error("Port configuration error found while trying to parse " + lPort
                    + ". Please check your Flashbridge port configuration section");
        }
    }
}

From source file:com.clustercontrol.poller.impl.MultipleOidsUtils.java

private PDU sendRequest(PDU request, Target target, ArrayList<OID> oidList) {
    request.clear();/*from   w ww .j a  va 2  s .c  o m*/
    for (OID oid : oidList) {
        VariableBinding vb = new VariableBinding(oid);
        request.add(vb);
        if (request.getBERLength() > target.getMaxSizeRequestPDU()) {
            request.trim();
            break;
        }
    }

    try {
        ResponseEvent event = session.send(request, target);
        if (checkResponse(event, target)) {
            PDU response = event.getResponse();
            return response;
        }
    } catch (IOException e) {
        log.warn(target.getAddress() + " sendRequest : " + e.getMessage());
    } catch (Exception e) {
        log.warn(target.getAddress() + " sendRequest : " + e.getClass().getName() + ", " + e.getMessage());
    }

    return null;
}

From source file:info.magnolia.cms.servlets.Spool.java

/**
 * @param resource File to be returned to the client
 * @param response HttpServletResponse//from w w  w .  j  av a  2  s . com
 * @return <code>true</code> if the file has been written to the servlet output stream without errors
 * @throws IOException for error in accessing the resource or the servlet output stream
 */
private boolean spool(File resource, HttpServletResponse response) throws IOException {
    FileInputStream in = new FileInputStream(resource);

    try {
        ServletOutputStream os = response.getOutputStream();
        byte[] buffer = new byte[8192];
        int read = 0;
        while ((read = in.read(buffer)) > 0) {
            os.write(buffer, 0, read);
        }
        os.flush();
        IOUtils.closeQuietly(os);
    } catch (IOException e) {
        // only log at debug level, tomcat usually throws a ClientAbortException anytime the user stop loading the
        // page
        if (log.isDebugEnabled())
            log.debug("Unable to spool resource due to a " + e.getClass().getName() + " exception", e); //$NON-NLS-1$ //$NON-NLS-2$
        return false;
    } finally {
        IOUtils.closeQuietly(in);
    }
    return true;
}

From source file:org.runbuddy.libtomahawk.infosystem.hatchet.HatchetInfoPlugin.java

/**
 * _fetch_ data from the Hatchet API (e.g. artist's top-hits, image etc.)
 *///w w w.j  a va  2s .c o  m
public void resolve(final InfoRequestData infoRequestData) {
    int priority;
    if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_ARTISTS_TOPHITSANDALBUMS) {
        priority = TomahawkRunnable.PRIORITY_IS_INFOSYSTEM_HIGH;
    } else if (infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_PLAYLISTS
            || infoRequestData.getType() == InfoRequestData.INFOREQUESTDATA_TYPE_USERS_LOVEDITEMS) {
        priority = TomahawkRunnable.PRIORITY_IS_INFOSYSTEM_LOW;
    } else {
        priority = TomahawkRunnable.PRIORITY_IS_INFOSYSTEM_MEDIUM;
    }
    TomahawkRunnable runnable = new TomahawkRunnable(priority) {
        @Override
        public void run() {
            try {
                boolean success = getParseConvert(infoRequestData);
                InfoSystem.get().reportResults(infoRequestData, success);
            } catch (IOException e) {
                Log.e(TAG, "resolve: " + e.getClass() + ": " + e.getLocalizedMessage());
            }
        }
    };
    ThreadManager.get().execute(runnable);
}

From source file:org.codelibs.fess.helper.CrawlingConfigHelper.java

public void writeContent(final Map<String, Object> doc) {
    if (logger.isDebugEnabled()) {
        logger.debug("writing the content of: " + doc);
    }//from   w  w  w.j a  v  a 2 s.  c  o  m
    final FieldHelper fieldHelper = ComponentUtil.getFieldHelper();
    final Object configIdObj = doc.get(fieldHelper.configIdField);
    if (configIdObj == null) {
        throw new FessSystemException("configId is null.");
    }
    final String configId = configIdObj.toString();
    if (configId.length() < 2) {
        throw new FessSystemException("Invalid configId: " + configIdObj);
    }
    final ConfigType configType = getConfigType(configId);
    CrawlingConfig config = null;
    if (logger.isDebugEnabled()) {
        logger.debug("configType: " + configType + ", configId: " + configId);
    }
    if (ConfigType.WEB == configType) {
        final WebCrawlingConfigService webCrawlingConfigService = SingletonS2Container
                .getComponent(WebCrawlingConfigService.class);
        config = webCrawlingConfigService.getWebCrawlingConfig(getId(configId));
    } else if (ConfigType.FILE == configType) {
        final FileCrawlingConfigService fileCrawlingConfigService = SingletonS2Container
                .getComponent(FileCrawlingConfigService.class);
        config = fileCrawlingConfigService.getFileCrawlingConfig(getId(configId));
    } else if (ConfigType.DATA == configType) {
        final DataCrawlingConfigService dataCrawlingConfigService = SingletonS2Container
                .getComponent(DataCrawlingConfigService.class);
        config = dataCrawlingConfigService.getDataCrawlingConfig(getId(configId));
    }
    if (config == null) {
        throw new FessSystemException("No crawlingConfig: " + configIdObj);
    }
    final String url = (String) doc.get(fieldHelper.urlField);
    final S2RobotClientFactory robotClientFactory = SingletonS2Container
            .getComponent(S2RobotClientFactory.class);
    config.initializeClientFactory(robotClientFactory);
    final S2RobotClient client = robotClientFactory.getClient(url);
    if (client == null) {
        throw new FessSystemException("No S2RobotClient: " + configIdObj + ", url: " + url);
    }
    final ResponseData responseData = client
            .execute(RequestDataBuilder.newRequestData().get().url(url).build());
    final HttpServletResponse response = ResponseUtil.getResponse();
    writeFileName(response, responseData);
    writeContentType(response, responseData);
    writeNoCache(response, responseData);
    InputStream is = null;
    OutputStream os = null;
    try {
        is = new BufferedInputStream(responseData.getResponseBody());
        os = new BufferedOutputStream(response.getOutputStream());
        StreamUtil.drain(is, os);
        os.flush();
    } catch (final IOException e) {
        if (!"ClientAbortException".equals(e.getClass().getSimpleName())) {
            throw new FessSystemException(
                    "Failed to write a content. configId: " + configIdObj + ", url: " + url, e);
        }
    } finally {
        IOUtils.closeQuietly(is);
        IOUtils.closeQuietly(os);
    }
    if (logger.isDebugEnabled()) {
        logger.debug("Finished to write " + url);
    }
}

From source file:net.community.chest.gitcloud.facade.AbstractContextInitializer.java

@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
    ConfigurableEnvironment environment = applicationContext.getEnvironment();
    MutablePropertySources propSources = environment.getPropertySources();
    ExtendedPlaceholderResolver sourcesResolver = ExtendedPlaceholderResolverUtils
            .toPlaceholderResolver(propSources);
    File appBase = resolveApplicationBase(propSources, sourcesResolver);
    File configFile = getApplicationConfigFile(appBase, sourcesResolver);
    Collection<String> activeProfiles = resolveActiveProfiles(sourcesResolver);
    if (ExtendedCollectionUtils.size(activeProfiles) > 0) {
        environment.setActiveProfiles(activeProfiles.toArray(new String[activeProfiles.size()]));
    }/*from ww  w  .ja  v  a 2  s  .  co  m*/

    try {
        ensureFoldersExistence(appBase, configFile, sourcesResolver);
    } catch (IOException e) {
        logger.error("ensureFoldersExistence(" + ExtendedFileUtils.toString(appBase) + ")" + " "
                + e.getClass().getSimpleName() + ": " + e.getMessage());
    }

    if (logger.isDebugEnabled()) {
        showArtifactsVersions();
    }
}

From source file:net.voidfunction.rm.common.FileRepository.java

/**
 * Saves this repository's HashMap of RMFiles to files.dat in the
 * repository's directory./*from   w  w w  .  j a  v a2 s . co  m*/
 * 
 * @throws IOException
 */
public void saveFiles() {
    try {
        String fileDatName = getFileName("files.dat");
        ObjectOutputStream out = new ObjectOutputStream(
                new BufferedOutputStream(new FileOutputStream(fileDatName)));
        out.writeObject(fileObjects);
        out.close();
    } catch (IOException e) {
        node.getLog()
                .severe("Could not save file database: " + e.getClass().toString() + " - " + e.getMessage());
    }
}

From source file:net.community.chest.gitcloud.facade.AbstractEnvironmentInitializer.java

protected void extractConfigFiles(File confDir, String resPrefix, Collection<String> names) {
    if (ConfigUtils.verifyFolderProperty(ConfigUtils.CONF_DIR_NAME, confDir)) {
        logger.info("extractConfigFiles(" + resPrefix + ") - created " + ExtendedFileUtils.toString(confDir));
    }/*from w w w.  j  av a  2s. c om*/

    ClassLoader cl = ExtendedClassUtils.getDefaultClassLoader(getClass());
    for (String fileName : names) {
        File targetFile = new File(confDir, fileName);
        if (targetFile.exists()) {
            logger.info("extractConfigFiles(" + fileName + ")[" + resPrefix + "] skip - already exists: "
                    + ExtendedFileUtils.toString(targetFile));
            continue;
        }

        try {
            long copyLength = extractConfigFile(cl.getResourceAsStream(resPrefix + "/" + fileName), targetFile,
                    getWorkBuf(ExtendedIOUtils.DEFAULT_BUFFER_SIZE_VALUE));
            if (copyLength <= 0L) {
                throw new StreamCorruptedException("Bad copy count: " + copyLength);
            }

            logger.info("extractConfigFiles(" + resPrefix + ")[" + fileName + "] " + copyLength + " bytes: "
                    + ExtendedFileUtils.toString(targetFile));
        } catch (IOException e) {
            RuntimeException thrown = new RuntimeException(
                    "extractConfigFiles(" + resPrefix + ")[" + fileName + "]" + " failed ("
                            + e.getClass().getSimpleName() + ")" + " to extract contents: " + e.getMessage(),
                    e);
            logger.warn(thrown.getMessage(), e);
            throw thrown;
        }
    }
}