Example usage for java.io IOException getLocalizedMessage

List of usage examples for java.io IOException getLocalizedMessage

Introduction

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

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:com.piketec.jenkins.plugins.tpt.TptPluginSlave.java

/**
 * It collects the necesary data (tpt exe path, tpt Port, tpt bindingname and tpt
 * expandedTptStartupWaitTime) from the environment. Then collects the necesary data from the
 * workload (put by the TptPluginMasterJobExecutor). After collecting all the necesary data it
 * creates a new TptPluginSlaveExecutor and execute it . This method will be called from Jenkins
 * when a build for a slave is scheduled. @see retryableJob. The logic is that the retryableJob
 * schedules builds for the slaves and those builds will be executed here.
 * /*from ww w . ja v  a 2s  . co  m*/
 * @return true if the slave executed successfully its workload.
 */
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
        throws InterruptedException, IOException {

    TptLogger logger = new TptLogger(listener.getLogger());
    EnvVars environment;
    try {
        environment = build.getEnvironment(launcher.getListener());
    } catch (IOException e) {
        environment = new EnvVars();
        logger.error(e.getLocalizedMessage());
    } catch (InterruptedException e) {
        logger.error(e.getLocalizedMessage());
        return false;
    }
    String[] expandedStringExePaths = environment.expand(exePaths).split("[,;]");
    FilePath[] expandedExePaths = new FilePath[expandedStringExePaths.length];
    for (int i = 0; i < expandedExePaths.length; i++) {
        expandedExePaths[i] = new FilePath(launcher.getChannel(),
                environment.expand(expandedStringExePaths[i].trim()));
    }
    int expandedTptPort;
    if (tptPort != null && !tptPort.isEmpty()) {
        try {
            expandedTptPort = Integer.parseInt(environment.expand(tptPort));
        } catch (NumberFormatException e) {
            logger.error("The given port " + environment.expand(tptPort) + " is not an integer."
                    + " Using default value.");
            expandedTptPort = DescriptorImpl.getDefaultTptPort();
        }
    } else {
        expandedTptPort = DescriptorImpl.getDefaultTptPort();
    }
    String expandedTptBindingName;
    if (tptBindingName != null && !tptBindingName.isEmpty()) {
        expandedTptBindingName = environment.expand(tptBindingName);
    } else {
        expandedTptBindingName = DescriptorImpl.getDefaultTptBindingName();
    }
    long expandedTptStartupWaitTime;
    if (tptStartUpWaitTime != null && !tptStartUpWaitTime.isEmpty()) {
        try {
            expandedTptStartupWaitTime = Integer.parseInt(environment.expand(tptStartUpWaitTime)) * 1000;
        } catch (NumberFormatException e) {
            logger.error("The given TPT startup waiting time " + environment.expand(tptStartUpWaitTime)
                    + " is not an integer. Using default value.");
            expandedTptStartupWaitTime = DescriptorImpl.getDefaultTptStartUpWaitTime() * 1000;
        }
    } else {
        expandedTptStartupWaitTime = DescriptorImpl.getDefaultTptStartUpWaitTime() * 1000;
    }

    String jobName = build.getProject().getName();
    WorkLoad workloadToDo = WorkLoad.pollWorkload(jobName);
    if (workloadToDo == null) {
        logger.error("Nothing todo. No work package for \"" + jobName + "\" enqueued.");
        return false;
    }

    String fileNameFromWorkload = workloadToDo.getFileName();
    String exeConfigFromWorkload = workloadToDo.getExeConfig();
    String testDataDirFromWorload = workloadToDo.getDataDir();
    String reportDirFromWorkload = workloadToDo.getReportDir();
    List<String> testCasesFromWorkload = workloadToDo.getTestCases();
    String testSetFromWorkload = workloadToDo.getTestSetName();
    AbstractBuild masterId = workloadToDo.getMasterId();
    FilePath masterWorkspace = workloadToDo.getMasterWorkspace();

    logger.info("File Name :               " + fileNameFromWorkload);
    logger.info("Execution Configuration : " + exeConfigFromWorkload);
    logger.info("Test Data directory :     " + testDataDirFromWorload);
    logger.info("Report directory :        " + reportDirFromWorkload);
    logger.info("Test Cases :              " + testCasesFromWorkload);
    if (StringUtils.isNotEmpty(testSetFromWorkload)) {
        logger.info("Test Set :                " + testSetFromWorkload);
    }

    TptPluginSlaveExecutor executor = new TptPluginSlaveExecutor(launcher, build, listener, expandedExePaths,
            expandedTptPort, expandedTptBindingName, new File(fileNameFromWorkload), exeConfigFromWorkload,
            testDataDirFromWorload, reportDirFromWorkload, testCasesFromWorkload, expandedTptStartupWaitTime,
            masterId, testSetFromWorkload, masterWorkspace);

    boolean result = executor.execute();
    if (!result) {
        // reenqueue for new try if job is configured to try multiple times
        WorkLoad.putWorkLoad(jobName, workloadToDo);
    }
    return result;
}

From source file:com.adr.mimame.PlatformList.java

public void init() {
    mimamememuhome = new File(System.getProperty("user.home"), ".mimamememu");

    // Loading default properties
    options = loadDefaults();//ww  w.  j  av a  2s .  c om

    // Load options file
    try (InputStream in = new FileInputStream(new File(mimamememuhome, "mimamememu.properties"))) {
        options.load(in);
    } catch (IOException ex) {
        logger.log(Level.INFO, ex.getLocalizedMessage());
    }

    // Load Properties
    fullscreen.set("fullscreen".equals(options.getProperty("display.mode")));

    // Load platform objects
    platforms = new Platform[] { new com.adr.mimame.platform.MameCommand(options),
            new com.adr.mimame.platform.SNESCommand(options),
            new com.adr.mimame.platform.ZXSpectrumCommand(options) };

    mediafactory = new MediaFactory(options);
}

From source file:com.freedomotic.plugins.devices.ipx800.Ipx800.java

/**
 * Actuator side// w  w w  .j  a va 2 s .  c  om
 * @throws com.freedomotic.exceptions.UnableToExecuteException    */
@Override
public void onCommand(Command c) throws UnableToExecuteException {
    //get connection paramentes address:port from received freedomotic command
    address = c.getProperty("address").split(DELIMITER);
    Board board = (Board) devices.get(address[0]);
    try {
        sendToBoard(board, c);
    } catch (IOException ex) {
        LOG.error("Impossibile to send command " + ex.getLocalizedMessage());
    }
}

From source file:jenkins.plugins.publish_over_ssh.BapHostConfiguration.java

@Override
public BapSshClient createClient(final BPBuildInfo buildInfo) {
    final JSch ssh = createJSch();
    final Session session = createSession(buildInfo, ssh);
    final BapSshClient bapClient = new BapSshClient(buildInfo, session, isEffectiveDisableExec());
    try {/*from  w w  w  .j a  va  2  s .  co  m*/
        final BapSshKeyInfo keyInfo = getEffectiveKeyInfo();
        final Properties sessionProperties = getSessionProperties();
        if (keyInfo.useKey()) {
            setKey(buildInfo, ssh, keyInfo);
            sessionProperties.put("PreferredAuthentications", "publickey");
        } else {
            session.setPassword(Util.fixNull(keyInfo.getPassphrase()));
        }
        session.setConfig(sessionProperties);
        connect(buildInfo, session);
        final ChannelSftp sftp = openSftpChannel(buildInfo, session);
        bapClient.setSftp(sftp);
        connectSftpChannel(buildInfo, sftp);
        changeToRootDirectory(bapClient);
        setRootDirectoryInClient(bapClient, sftp);
        return bapClient;
    } catch (IOException ioe) {
        bapClient.disconnectQuietly();
        throw new BapPublisherException(Messages.exception_failedToCreateClient(ioe.getLocalizedMessage()),
                ioe);
    } catch (RuntimeException re) {
        bapClient.disconnectQuietly();
        throw re;
    }
}

From source file:de.badw.strauss.glyphpicker.controller.alltab.TeiLoadWorker.java

/**
 * Loads data from a file./*from  www  .  j ava2  s. co m*/
 *
 * @return the resulting GlyphDefinition list
 */
public List<GlyphDefinition> loadDataFromFile() {

    String fileName = dataSource.getBasePath();

    if (fileName != null) {
        File file = new File(fileName);
        InputStream inputStream = null;

        try {
            inputStream = new FileInputStream(file);
        } catch (IOException e) {
            JOptionPane.showMessageDialog(
                    null, String.format(i18n.getString("TeiLoadWorker.couldNotLoadData"),
                            e.getLocalizedMessage(), fileName),
                    i18n.getString("TeiLoadWorker.error"), JOptionPane.ERROR_MESSAGE);
            LOGGER.info(e);
        }
        if (inputStream != null) {
            return parseXmlSax(inputStream);
        }
    }
    return null;
}

From source file:com.alphabetbloc.accessmrs.services.SyncAdapter.java

/**
 * Compares the current form list on the server with the forms on disk
 * //from   w ww .  j  ava 2  s. c  o  m
 * @return a list of the new forms on the server
 */
private Form[] findNewFormsOnServer(HttpClient client, SyncResult syncResult) {

    // find all forms from server
    ArrayList<Form> allServerForms = new ArrayList<Form>();
    try {
        InputStream is = NetworkUtils.getStream(client, NetworkUtils.getFormListDownloadUrl());
        allServerForms = mSyncManager.readFormListStream(is);
        is.close();

    } catch (IOException e) {
        mTimeoutException = e.getLocalizedMessage();
        Log.e(TAG, "Connection Timeout Exception... ");
        e.printStackTrace();
        ++syncResult.stats.numIoExceptions;
    } catch (Exception e) {
        e.printStackTrace();
        ++syncResult.stats.numIoExceptions;
    }

    // compare to existing forms
    ArrayList<Form> newForms = new ArrayList<Form>();
    for (int i = 0; i < allServerForms.size(); i++) {
        Form f = allServerForms.get(i);
        String formId = f.getFormId() + "";
        if (!FileUtils.doesXformExist(formId))
            newForms.add(f);
    }

    // return new forms
    return newForms.toArray(new Form[newForms.size()]);
}

From source file:com.yoctopuce.YoctoAPI.YCallbackHub.java

@Override
synchronized void updateDeviceList(boolean forceupdate) throws YAPI_Exception {

    long now = YAPI.GetTickCount();
    if (forceupdate) {
        _devListExpires = 0;//from w w w  . j a  va 2s.co m
    }
    if (_devListExpires > now) {
        return;
    }
    String yreq;
    try {
        yreq = new String(cachedRequest("GET /api.json\r\n", null));
    } catch (IOException ex) {
        throw new YAPI_Exception(YAPI.IO_ERROR, ex.getLocalizedMessage());
    }
    HashMap<String, ArrayList<YPEntry>> yellowPages = new HashMap<String, ArrayList<YPEntry>>();
    ArrayList<WPEntry> whitePages = new ArrayList<WPEntry>();
    JSONObject loadval;
    try {
        loadval = new JSONObject(yreq);
        if (!loadval.has("services") || !loadval.getJSONObject("services").has("whitePages")) {
            throw new YAPI_Exception(YAPI.INVALID_ARGUMENT,
                    "Device " + _http_params.getHost() + " is not a hub");
        }

        JSONArray whitePages_json = loadval.getJSONObject("services").getJSONArray("whitePages");
        JSONObject yellowPages_json = loadval.getJSONObject("services").getJSONObject("yellowPages");

        // Reindex all functions from yellow pages
        //HashMap<String, Boolean> refresh = new HashMap<String, Boolean>();
        Iterator<?> keys = yellowPages_json.keys();
        while (keys.hasNext()) {
            String classname = keys.next().toString();
            JSONArray yprecs_json = yellowPages_json.getJSONArray(classname);
            ArrayList<YPEntry> yprecs_arr = new ArrayList<YPEntry>(yprecs_json.length());
            for (int i = 0; i < yprecs_json.length(); i++) {
                YPEntry yprec = new YPEntry(yprecs_json.getJSONObject(i));
                yprecs_arr.add(yprec);

            }
            yellowPages.put(classname, yprecs_arr);
        }

        // Reindex all devices from white pages
        for (int i = 0; i < whitePages_json.length(); i++) {
            JSONObject jsonObject = whitePages_json.getJSONObject(i);
            WPEntry devinfo = new WPEntry(jsonObject);
            int index = jsonObject.getInt("index");
            _serialByYdx.put(index, devinfo.getSerialNumber());
            whitePages.add(devinfo);
        }
    } catch (JSONException e) {
        throw new YAPI_Exception(YAPI.IO_ERROR,
                "Request failed, could not parse API result for " + _http_params.getHost(), e);
    }
    updateFromWpAndYp(whitePages, yellowPages);

    // reset device list cache timeout for this hub
    now = YAPI.GetTickCount();
    _devListExpires = now + _devListValidity;
}

From source file:com.kylinolap.job.flow.JobFlowListener.java

private void handleException(String jobInstanceUuid, int jobInstanceStepSeqId, KylinConfig config,
        Throwable t) {// w w w. j ava 2 s.c om
    log.error(t.getLocalizedMessage(), t);
    String exceptionMsg = "Failed with Exception:" + ExceptionUtils.getFullStackTrace(t);
    try {
        JobInstance jobInstance = JobDAO.getInstance(config).getJob(jobInstanceUuid);
        jobInstance.getSteps().get(jobInstanceStepSeqId).setStatus(JobStepStatusEnum.ERROR);
        // String output =
        // jobInstance.getSteps().get(jobInstanceStepSeqId).getCmdOutput();
        // jobInstance.getSteps().get(jobInstanceStepSeqId).setCmdOutput(output
        // + "\n" + exceptionMsg);
        jobInstance.getSteps().get(jobInstanceStepSeqId).setExecEndTime(System.currentTimeMillis());
        JobDAO.getInstance(config).updateJobInstance(jobInstance);

        String output = JobDAO.getInstance(config).getJobOutput(jobInstanceUuid, jobInstanceStepSeqId)
                .getOutput();
        output = output + "\n" + exceptionMsg;
        JobDAO.getInstance(config).saveJobOutput(jobInstanceUuid, jobInstanceStepSeqId, output);
    } catch (IOException e1) {
        log.error(e1.getLocalizedMessage(), e1);
    }
}

From source file:com.epam.dlab.backendapi.core.commands.CommandParserMock.java

/**
 * Extract Json properties from Json content.
 *
 * @param jsonContent Json content.//  w  ww.  j a v a2  s  .com
 * @return
 */
private Map<String, String> getJsonVariables(String jsonContent) {
    Map<String, String> vars = new HashMap<>();
    if (jsonContent == null) {
        return vars;
    }

    JsonNode json;
    try {
        json = MAPPER.readTree(jsonContent);
    } catch (IOException e) {
        throw new DlabException("Can't parse json content: " + e.getLocalizedMessage(), e);
    }

    Iterator<String> keys = json.fieldNames();
    while (keys.hasNext()) {
        String key = keys.next();
        String value = getTextValue(json.get(key));
        if (value != null) {
            vars.put(key, value);
        }
    }
    return vars;
}

From source file:com.alphabetbloc.accessmrs.services.SyncAdapter.java

public String[] uploadInstances(HttpClient client, String[] instancePaths, SyncResult syncResult) {
    SyncManager.sLoopProgress.set(0);//from  www .j av  a 2s.c  o  m
    SyncManager.sLoopCount.set(instancePaths.length);
    ArrayList<String> uploadedInstances = new ArrayList<String>();
    for (int i = 0; i < instancePaths.length; i++) {

        if (mTimeoutException != null)
            break;

        try {
            String instancePath = FileUtils.getDecryptedFilePath(instancePaths[i]);
            MultipartEntity entity = NetworkUtils.createMultipartEntity(instancePath);
            if (entity == null)
                continue;

            NetworkUtils.postEntity(client, NetworkUtils.getFormUploadUrl(), entity);
            if (App.DEBUG)
                Log.v(TAG, "everything okay! added an instance...");
            uploadedInstances.add(instancePaths[i]);

        } catch (IOException e) {
            mTimeoutException = e.getLocalizedMessage();
            Log.e(TAG, "Connection Timeout Exception... ");
            e.printStackTrace();
            ++syncResult.stats.numIoExceptions;
        } catch (Exception e) {
            Log.e(TAG, "Exception on uploading instance =" + instancePaths[i]);
            e.printStackTrace();
            ++syncResult.stats.numIoExceptions;
        }

        SyncManager.sLoopProgress.getAndIncrement();
    }

    return uploadedInstances.toArray(new String[uploadedInstances.size()]);
}