Example usage for java.io IOException toString

List of usage examples for java.io IOException toString

Introduction

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

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:hudson.plugins.clearcase.action.SnapshotCheckoutAction.java

public boolean checkout(Launcher launcher, FilePath workspace, String viewTag)
        throws IOException, InterruptedException {
    boolean viewCreated = cleanAndCreateViewIfNeeded(workspace, viewTag, viewPath, null);

    // At this stage, we have a valid view and a valid path
    boolean needSetCs = true;
    AbstractCheckoutAction.LoadRulesDelta loadRulesDelta = null;
    if (!viewCreated) {
        ConfigSpec viewConfigSpec = new ConfigSpec(cleartool.catcs(viewTag), launcher.isUnix());
        loadRulesDelta = getLoadRulesDelta(viewConfigSpec.getLoadRules(), launcher);
        needSetCs = !configSpec.stripLoadRules().equals(viewConfigSpec.stripLoadRules())
                || !ArrayUtils.isEmpty(loadRulesDelta.getRemoved());
    }//  w ww  .  j a  v a2  s  . c  om

    if (needSetCs) {
        try {
            cleartool.setcs(viewPath, SetcsOption.CONFIGSPEC, configSpec.setLoadRules(loadRules).getRaw());
        } catch (IOException e) {
            launcher.getListener().fatalError(e.toString());
            return false;
        }
    } else {
        String[] addedLoadRules = loadRulesDelta.getAdded();
        if (!ArrayUtils.isEmpty(addedLoadRules)) {
            // Config spec haven't changed, but there are new load rules
            try {
                cleartool.update(viewPath, addedLoadRules);
            } catch (IOException e) {
                launcher.getListener().fatalError(e.toString());
                return false;
            }
        }
    }
    // Perform a full update of the view. to reevaluate config spec
    if (!viewCreated) {
        try {
            cleartool.setcs(viewPath, SetcsOption.CURRENT, null);
        } catch (IOException e) {
            launcher.getListener().fatalError(e.toString());
            return false;
        }
    }
    return true;
}

From source file:hudson.plugins.clearcase.action.UcmSnapshotCheckoutAction.java

@Override
public boolean checkout(Launcher launcher, FilePath workspace, String viewTag)
        throws IOException, InterruptedException {
    boolean viewCreated = cleanAndCreateViewIfNeeded(workspace, viewTag, viewPath, streamSelector);
    // At this stage, we have a valid view and a valid path
    if (viewCreated) {
        // If the view is brand new, we just have to add the load rules
        try {//from  w ww . java  2s .c  o m
            cleartool.update(viewPath, loadRules);
        } catch (IOException e) {
            launcher.getListener().fatalError(e.toString());
            return false;
        }
    } else {
        ConfigSpec viewConfigSpec = new ConfigSpec(cleartool.catcs(viewTag), launcher.isUnix());
        AbstractCheckoutAction.LoadRulesDelta loadRulesDelta = getLoadRulesDelta(viewConfigSpec.getLoadRules(),
                launcher);
        if (!ArrayUtils.isEmpty(loadRulesDelta.getRemoved())) {
            try {
                cleartool.setcs(viewPath, SetcsOption.CONFIGSPEC,
                        viewConfigSpec.setLoadRules(loadRules).getRaw());
            } catch (IOException e) {
                launcher.getListener().fatalError(e.toString());
                return false;
            }
        } else {
            String[] addedLoadRules = loadRulesDelta.getAdded();
            if (!ArrayUtils.isEmpty(addedLoadRules)) {
                // Config spec haven't changed, but there are new load rules
                try {
                    cleartool.update(viewPath, addedLoadRules);
                } catch (IOException e) {
                    launcher.getListener().fatalError(e.toString());
                    return false;
                }
            }
        }

        // Perform a full update of the view to get changes due to rebase for instance.
        try {
            cleartool.update(viewPath, null);
        } catch (IOException e) {
            launcher.getListener().fatalError(e.toString());
            return false;
        }
    }
    return true;
}

From source file:org.efs.openreports.actions.ReportViewerAction.java

public String execute() {
    JasperPrint jasperPrint = (JasperPrint) ActionContext.getContext().getSession().get(ORStatics.JASPERPRINT);

    report = (Report) ActionContext.getContext().getSession().get(ORStatics.REPORT);

    if (jasperPrint != null && jasperPrint.getPages() != null) {
        pageCount = jasperPrint.getPages().size();
    }/*from ww w  . j a  v a  2  s. com*/

    if (!"image".equals(submitType))
        return SUCCESS;

    byte[] imageData = null;

    if (jasperPrint != null) {
        try {
            BufferedImage image = (BufferedImage) JasperPrintManager.printPageToImage(jasperPrint,
                    pageIndex - 1, zoom);
            imageData = new SunPNGEncoderAdapter().encode(image);
        } catch (Exception e) {
            addActionError(e.getMessage());
            log.error(e.toString());
        }
    }

    if (imageData != null) {

        HttpServletResponse response = ServletActionContext.getResponse();

        try {
            response.setContentLength(imageData.length);
            ServletOutputStream ouputStream = response.getOutputStream();
            ouputStream.write(imageData, 0, imageData.length);
            ouputStream.flush();
            ouputStream.close();
        } catch (IOException ioe) {
            log.warn(ioe.toString());
        }
    }

    return NONE;
}

From source file:com.logicalpractice.flumechronicle.channel.ChronicleCleanup.java

@Override
public void run() {
    long currentPosition = position.get();
    if (currentPosition == 0) {
        return; // no work to do as nothing has been
    }//from w  ww.  jav a2 s.co m
    // stolen from VanillaChronicle
    int entriesForCycleBits = Maths.intLog2(queueBuilder.entriesPerCycle());
    int cycle = (int) (currentPosition >>> entriesForCycleBits);

    String currentCycleFolder = dateCache.formatFor(cycle);

    File[] directories = path.listFiles(directoriesLessThan(currentCycleFolder));

    for (File directory : directories) {
        logger.info("deleting {}", directory);
        try {
            FileUtils.deleteDirectory(directory);
        } catch (IOException e) {
            logger.warn("unable to remove directory {} - {}", directory, e.toString());
        }
    }
}

From source file:com.streamsets.lib.security.http.DisconnectedSecurityInfo.java

public String toJsonString() {
    try {//www .j av a2  s  .c  o  m
        return OBJECT_MAPPER.writeValueAsString(this);
    } catch (IOException ex) {
        throw new RuntimeException("Should never happen: " + ex.toString(), ex);
    }
}

From source file:io.lightlink.excel.CopyingTemplateHandler.java

protected void emit(String s) {
    try {//w  w  w  .  ja  va  2  s .  co  m
        out.write(s);
        out.flush();
    } catch (IOException e) {
        throw new RuntimeException(e.toString(), e);
    }
}

From source file:com.nubits.nubot.NTP.NTPClient.java

public Date getTime() {
    initHosts();//from   w  w w . j  a v  a 2s . co  m
    boolean found = false;
    for (int i = 0; i < hostnames.size(); i++) {
        try {
            return getTimeImpl(hostnames.get(i));
        } catch (IOException ex) {
            LOG.warning("Problem with timeserver " + hostnames.get(i) + "" + "\n" + ex.toString());
            if (i != hostnames.size() - 1) {
                LOG.info("Trying next server");
            }
        }
    }
    if (!found) {
        LOG.severe("Cannot update time after querying " + hostnames.size() + " timeservers. ");
        System.exit(0);
    }
    return new Date(); //statement is never reached

}

From source file:mvc.controller.UsuarioController.java

@RequestMapping(value = "/adicionaUsuario", method = RequestMethod.POST)
public String adiciona(HttpServletRequest request, Model model) {
    /*//from   ww  w  . j  a  v a  2s. c  o m
    Configuracoes necessrias
    Fonte: http://www.pablocantero.com/blog/2010/09/29/upload-com-spring-mvc/
    */
    try {
        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
        MultipartFile multipartFile = multipartRequest.getFile("photo");

        String destinyPath = "C:\\PhotosNetbeans\\";
        if (!(new File(destinyPath)).exists()) {
            (new File(destinyPath)).mkdir();
        }

        String photoName = multipartFile.getOriginalFilename();
        String photoPath = destinyPath + photoName;

        File photoFile = new File(photoPath);
        multipartFile.transferTo(photoFile);

        //backup
        //File destinationDir = new File(applicationPath);
        //FileUtils.copyFileToDirectory(photoFile, destinationDir);

        Usuario user = new Usuario();
        user.setLogin(request.getParameter("login"));
        user.setSenha(request.getParameter("senha"));
        user.setPhoto(photoPath);

        dao.adicionaUsuario(user);
        return "usuario/usuario-adicionado";

    } catch (IOException ex) {
        model.addAttribute("erro", ex.toString());
        return "usuario/usuario-erro-adicao";
    }
}

From source file:io.github.retz.db.Jobs.java

public List<Job> getAllRunning() throws SQLException {
    List<Job> ret = new LinkedList<>();
    try (PreparedStatement p = conn
            .prepareStatement("SELECT json FROM jobs WHERE state='STARTING' OR state='STARTED'");
            ResultSet res = p.executeQuery()) {
        while (res.next()) {
            String json = res.getString("json");
            ret.add(mapper.readValue(json, Job.class));
        }//from   w ww .  j  av a 2  s .  c  o m
        for (Job job : ret) {
            job.doRetry();
            LOG.info("Retrying job: {}", job);
            updateJob(job);
        }
    } catch (IOException e) {
        throw new RuntimeException("Broken JSON: " + e.toString());
    }
    return ret;
}

From source file:com.juick.android.JettyWsClient.java

public boolean send(String str) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try {// ww  w . j  av a2s.  c om
        byte[] bytes = str.getBytes("utf-8");
        baos.write(0x81);
        baos.write((byte) bytes.length);
        baos.write(bytes);
        os.write(baos.toByteArray());
        os.flush();
        return true;
    } catch (IOException e) {
        System.out.println("WS send:" + e.toString());
        return false;
    }
}