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.kylinolap.job.flow.JobFlowNode.java

protected void handleException(String jobInstanceUuid, int jobInstanceStepSeqId, KylinConfig config,
        Throwable t) {/*from ww  w. ja  v a 2 s .  c o  m*/
    log.error(t.getLocalizedMessage(), t);
    String exceptionMsg = "Failed with Exception:" + ExceptionUtils.getFullStackTrace(t);
    try {
        JobDAO dao = JobDAO.getInstance(config);
        JobInstance jobInstance = dao.getJob(jobInstanceUuid);
        JobStep jobStep = jobInstance.getSteps().get(jobInstanceStepSeqId);
        jobStep.setStatus(JobStepStatusEnum.ERROR);
        jobStep.setExecEndTime(System.currentTimeMillis());
        dao.updateJobInstance(jobInstance);

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

From source file:com.ebay.pulsar.websocket.WebSocketConnectionManager.java

public void broadcast(String channel, JetstreamEvent event) {
    if (sockets.size() > 0) {
        String message = JsonUtil.toJson(event);
        for (MetricWebSocket socket : sockets) {
            try {
                if (socket.getChannles().contains(event.getEventType())) {
                    socket.getRemote().sendString(message);
                    lastSuccessMessage = message;
                    incrementEventSentCounter();
                }//from  w  w w . ja  v  a2s. c  o m
            } catch (IOException e) {
                logger.error(e.getLocalizedMessage(), e);
                registerError(e);
            }
        }
    }
}

From source file:com.networkmanagerapp.RestartWifi.java

/**
 * Requests the restart of WIFI in the background
 * @param arg0 the data to process in the background
 * @throws IOException caught locally. Catch throws NullPointerException, also caught internally.
 *///from  w w  w. j  av  a2 s  .com
@Override
protected void onHandleIntent(Intent arg0) {
    mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
    showNotification();
    try {
        String password = PreferenceManager.getDefaultSharedPreferences(this).getString("password_preference",
                "");
        String ip = PreferenceManager.getDefaultSharedPreferences(this).getString("ip_preference",
                "192.168.1.1");
        String enc = URLEncoder.encode(ip, "utf-8");
        String scriptUrl = "http://" + enc + ":1080/cgi-bin/wifi.sh";
        HttpParams httpParams = new BasicHttpParams();
        // Set the timeout in milliseconds until a connection is established.
        int timeoutConnection = 3000;
        HttpConnectionParams.setConnectionTimeout(httpParams, timeoutConnection);
        // Set the default socket timeout (SO_TIMEOUT) 
        // in milliseconds which is the timeout for waiting for data.
        int timeoutSocket = 5000;
        HttpConnectionParams.setSoTimeout(httpParams, timeoutSocket);
        HttpHost targetHost = new HttpHost(enc, 1080, "http");
        DefaultHttpClient client = new DefaultHttpClient(httpParams);
        client.getCredentialsProvider().setCredentials(
                new AuthScope(targetHost.getHostName(), targetHost.getPort()),
                new UsernamePasswordCredentials("root", password));
        HttpGet request = new HttpGet(scriptUrl);
        client.execute(targetHost, request);
    } catch (IOException ex) {
        try {
            Log.e("Network Manager reboot", ex.getLocalizedMessage());
        } catch (NullPointerException e) {
            Log.e("Network Manager reboot", "Rebooting, " + e.getLocalizedMessage());
        }

    } finally {
        mNM.cancel(R.string.wifi_service_restarted);
        stopSelf();
    }
}

From source file:net.osten.watermap.batch.FetchPCTWaypointsJob.java

private void unZipIt(File zipFile, File outputFolder) {
    byte[] buffer = new byte[1024];

    try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile))) {
        // get the zipped file list entry
        ZipEntry ze = zis.getNextEntry();
        while (ze != null) {
            String fileName = ze.getName();
            File newFile = new File(outputFolder.getAbsolutePath() + File.separator + fileName);

            log.log(Level.FINER, "file unzip : {0}", new Object[] { newFile.getAbsoluteFile() });

            // create all non existing folders else you will hit FileNotFoundException for compressed folder
            new File(newFile.getParent()).mkdirs();

            try (FileOutputStream fos = new FileOutputStream(newFile)) {
                int len;
                while ((len = zis.read(buffer)) > 0) {
                    fos.write(buffer, 0, len);
                }/*  w w  w.jav a  2 s. c o  m*/
            }
            ze = zis.getNextEntry();

            // move newFile to data directory
            try {
                // have to delete first since FileUtils does not overwrite
                File destinationFile = new File(outputFolder + File.separator + newFile.getName());
                if (destinationFile.exists()) {
                    destinationFile.delete();
                }
                FileUtils.moveFileToDirectory(newFile, outputFolder, false);
            } catch (FileExistsException ioe) {
                log.warning(ioe.getLocalizedMessage());
            } catch (IOException ioe) {
                log.warning(ioe.getLocalizedMessage());
            }
        }

        // close the last entry
        zis.closeEntry();
    } catch (IOException e) {
        log.warning(e.getLocalizedMessage());
    }
}

From source file:com.websocket.WebSocketNewAnn.java

/**
 * ?void()//  w w w . ja  v  a2  s.  c o m
 * 
 * @param sendMsg
 */
public void sendNewAnnMsgToAll(String sendMsg) {
    int userID = -1;
    try {
        for (Entry<Integer, Session> entry : userSessions.entrySet()) {
            if (entry.getValue().isOpen()) {
                userID = Integer.parseInt(entry.getKey().toString());
                entry.getValue().getBasicRemote().sendText(sendMsg);
            }
        }
    } catch (IOException e) {
        logger.error("?UserID:" + userID + "WebSocket?:" + e.getLocalizedMessage());
    }
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.snpData.SetPlatformListener.java

@Override
public void handleEvent(Event event) {
    Vector<String> values = this.ui.getValues();
    Vector<String> samples = this.ui.getSamples();
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".subject_mapping.tmp");
    File mappingFile = ((SnpData) this.dataType).getMappingFile();
    if (mappingFile == null) {
        this.ui.displayMessage("Error: no subject to sample mapping file");
    }//  w  ww.j  a va2s  .  c  o m
    try {
        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);

        try {
            BufferedReader br = new BufferedReader(new FileReader(mappingFile));
            String line;
            while ((line = br.readLine()) != null) {
                String[] fields = line.split("\t", -1);
                String sample = fields[3];
                String platform;
                if (samples.contains(sample)) {
                    platform = values.get(samples.indexOf(sample));
                } else {
                    br.close();
                    return;
                }
                out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + platform
                        + "\t" + fields[5] + "\t" + fields[6] + "\t" + fields[7] + "\t" + fields[8] + "\n");
            }
            br.close();
        } catch (Exception e) {
            this.ui.displayMessage("Error: " + e.getLocalizedMessage());
            out.close();
            e.printStackTrace();
        }
        out.close();
        try {
            File fileDest;
            if (mappingFile != null) {
                String fileName = mappingFile.getName();
                mappingFile.delete();
                fileDest = new File(this.dataType.getPath() + File.separator + fileName);
            } else {
                fileDest = new File(this.dataType.getPath() + File.separator
                        + this.dataType.getStudy().toString() + ".subject_mapping");
            }
            FileUtils.moveFile(file, fileDest);
            ((SnpData) this.dataType).setMappingFile(fileDest);
        } catch (IOException ioe) {
            this.ui.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.ui.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.ui.displayMessage("Subject to sample mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

From source file:com.ebay.pulsar.websocket.WebSocketConnectionManager.java

public void broadcast(String channel, List<Queue<JetstreamEvent>> eventsList) {
    lastBroadCastbatch.put(channel, eventsList);
    for (MetricWebSocket socket : sockets) {
        try {/*from w  w w. ja  v  a 2s.  co m*/
            List<JetstreamEvent> eventsFilteredForSocket = new ArrayList<JetstreamEvent>();
            for (Queue<JetstreamEvent> events : eventsList) {
                for (JetstreamEvent event : events) {
                    if (socket.getChannles().contains(event.getEventType())) {
                        eventsFilteredForSocket.add(event);
                    }
                }
            }
            if (eventsFilteredForSocket.size() > 0) {
                String message = JsonUtil.toJson(eventsFilteredForSocket);
                socket.getRemote().sendString(message);
                lastSuccessMessage = message;
            }
            incrementEventSentCounter();
        } catch (IOException e) {
            logger.error(e.getLocalizedMessage(), e);
            registerError(e);
        }
    }
}

From source file:jmupen.MyListSelectionListener.java

@Override
public void mousePressed(MouseEvent e) {
    list.setSelectedIndex(list.locationToIndex(e.getPoint()));
    int index = list.getSelectedIndex();
    if (SwingUtilities.isRightMouseButton(e)) {
        JPopupMenu menu = new JPopupMenu();
        JMenuItem item = new JMenuItem("Remove");
        item.addActionListener(new ActionListener() {
            @Override/*from  w w  w . j a v  a 2  s. co m*/
            public void actionPerformed(ActionEvent e) {
                if (index != -1) {
                    try {
                        System.out.println("Linea: " + index + " " + model.get(index));
                        model.removeElementAt(index);
                        removeLines(index, JMupenUtils.getRecents().toFile());
                        JMupenUtils.setGames(JMupenUtils.getGamesFromFile(JMupenUtils.getRecents()));
                    } catch (IOException ex) {
                        System.err.println("Error removing recent game. " + ex.getLocalizedMessage());
                    }
                }
            }
        });
        menu.add(item);
        menu.show(list, e.getX(), e.getY());
    }
}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.snpData.SetTissueListener.java

@Override
public void handleEvent(Event event) {
    Vector<String> values = this.ui.getValues();
    Vector<String> samples = this.ui.getSamples();
    File file = new File(this.dataType.getPath().toString() + File.separator
            + this.dataType.getStudy().toString() + ".subject_mapping.tmp");
    File mappingFile = ((SnpData) this.dataType).getMappingFile();
    if (mappingFile == null) {
        this.ui.displayMessage("Error: no subject to sample mapping file");
    }//from  ww w .  j  a  v a2 s.  co m
    try {
        FileWriter fw = new FileWriter(file);
        BufferedWriter out = new BufferedWriter(fw);

        try {
            BufferedReader br = new BufferedReader(new FileReader(mappingFile));
            String line;
            while ((line = br.readLine()) != null) {
                String[] fields = line.split("\t", -1);
                String sample = fields[3];
                String tissueType;
                if (samples.contains(sample)) {
                    tissueType = values.get(samples.indexOf(sample));
                } else {
                    br.close();
                    return;
                }
                out.write(fields[0] + "\t" + fields[1] + "\t" + fields[2] + "\t" + sample + "\t" + fields[4]
                        + "\t" + tissueType + "\t" + fields[6] + "\t" + fields[7] + "\t" + "PLATFORM+TISSUETYPE"
                        + "\n");
            }
            br.close();
        } catch (Exception e) {
            this.ui.displayMessage("File error: " + e.getLocalizedMessage());
            out.close();
            e.printStackTrace();
        }
        out.close();
        try {
            File fileDest;
            if (mappingFile != null) {
                String fileName = mappingFile.getName();
                mappingFile.delete();
                fileDest = new File(this.dataType.getPath() + File.separator + fileName);
            } else {
                fileDest = new File(this.dataType.getPath() + File.separator
                        + this.dataType.getStudy().toString() + ".subject_mapping");
            }
            FileUtils.moveFile(file, fileDest);
            ((SnpData) this.dataType).setMappingFile(fileDest);
        } catch (IOException ioe) {
            this.ui.displayMessage("File error: " + ioe.getLocalizedMessage());
            return;
        }
    } catch (Exception e) {
        this.ui.displayMessage("Error: " + e.getLocalizedMessage());
        e.printStackTrace();
    }
    this.ui.displayMessage("Subject to sample mapping file updated");
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

From source file:com.ebay.pulsar.websocket.WebSocketConnectionManager.java

public void broadcastToSession(MetricWebSocket socket) {
    for (String channel : lastBroadCastbatch.keySet()) {
        List<Queue<JetstreamEvent>> eventsList = lastBroadCastbatch.get(channel);
        if (eventsList != null && eventsList.size() > 0) {
            try {
                List<JetstreamEvent> eventsFilteredForSocket = new ArrayList<JetstreamEvent>();
                for (Queue<JetstreamEvent> events : eventsList) {
                    for (JetstreamEvent event : events) {
                        if (socket.getChannles().contains(event.getEventType())) {
                            eventsFilteredForSocket.add(event);
                        }//w ww .j  a va 2 s  .  com
                    }
                }
                if (eventsFilteredForSocket.size() > 0) {
                    String message = JsonUtil.toJson(eventsFilteredForSocket);
                    socket.getRemote().sendString(message);
                    lastSuccessMessage = message;
                }
                incrementEventSentCounter();
            } catch (IOException e) {
                logger.error(e.getLocalizedMessage(), e);
                registerError(e);
            }
        }
    }
}