Package hudson.util

Examples of hudson.util.IOException2


                    form = e;
                    break;
                }
            }
        } catch (IOException e) {
            throw new IOException2("Failed to access "+url,e);
        }

        url = new URL(form.attributeValue("action"));
        try {
            HttpURLConnection con = (HttpURLConnection) ProxyConfiguration.open(url);
            con.setRequestMethod("POST");
            con.setDoOutput(true);
            con.setRequestProperty("Cookie",cookie);
            con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
            PrintStream os = new PrintStream(con.getOutputStream());

            // select platform
            String primary=null,secondary=null;
            Element p = (Element)form.selectSingleNode(".//select[@id='dnld_platform']");
            for (Element opt : (List<Element>)p.elements("option")) {
                String value = opt.attributeValue("value");
                String vcap = value.toUpperCase(Locale.ENGLISH);
                if(!platform.is(vcap))  continue;
                switch (cpu.accept(vcap)) {
                case PRIMARY:   primary = value;break;
                case SECONDARY: secondary=value;break;
                case UNACCEPTABLE:  break;
                }
            }
            if(primary==null)   primary=secondary;
            if(primary==null)
            throw new AbortException("Couldn't find the right download for "+platform+" and "+ cpu +" combination");
            os.print(p.attributeValue("name")+'='+primary);
            LOGGER.fine("Platform choice:"+primary);

            // select language
            Element l = (Element)form.selectSingleNode(".//select[@id='dnld_language']");
            if (l != null) {
                os.print("&"+l.attributeValue("name")+"="+l.element("option").attributeValue("value"));
            }

            // the rest
            for (Element e : (List<Element>)form.selectNodes(".//input")) {
                os.print('&');
                os.print(e.attributeValue("name"));
                os.print('=');
                String value = e.attributeValue("value");
                if(value==null)
                    os.print("on"); // assume this is a checkbox
                else
                    os.print(URLEncoder.encode(value,"UTF-8"));
            }
            os.close();
            return con;
        } catch (IOException e) {
            throw new IOException2("Failed to access "+url,e);
        }
    }
View Full Code Here


                            .newTransformer();
                    t.transform(new StreamSource(req.getReader()),
                            new StreamResult(out));
                    out.close();
                } catch (TransformerException e) {
                    throw new IOException2("Failed to persist configuration.xml", e);
                }

                // try to reflect the changes by reloading
                new XmlFile(Items.XSTREAM, out.getTemporaryFile()).unmarshal(this);
                onLoad(getParent(), getRootDir().getName());
View Full Code Here

                    boolean produced = buildTimestamp <= file.lastModified()+2000;

                    try {
                        results.add(new Record(produced,f,file.getName(),new FilePath(file).digest()));
                    } catch (IOException e) {
                        throw new IOException2(Messages.Fingerprinter_DigestFailed(file),e);
                    } catch (InterruptedException e) {
                        throw new IOException2(Messages.Fingerprinter_Aborted(),e);
                    }
                }

                return results;
            }
View Full Code Here

                    throw new IOException(
                            "Could not connect to " + url.toExternalForm() + ". Connection timed out after " + TIME_OUT_RETRY_COUNT + " tries.");
                }
                connected = false;
            } catch (UnknownHostException exc) {
                throw new IOException2(
                        "Could not connect to " + url.toExternalForm() + ". Check your internet connection.",
                        exc);
            } catch (ConnectException exc) {
                throw new IOException2(
                        "Could not connect to " + url.toExternalForm() + ". Check your internet connection.",
                        exc);
            }
        }
View Full Code Here

            } finally {
                in.close();
            }
            return toHexString(md5.digest());
        } catch (NoSuchAlgorithmException e) {
            throw new IOException2("MD5 not installed",e);    // impossible
        }
    }
View Full Code Here

    public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
        try {
            serveFile(req,rsp,base,icon,serveDirIndex);
        } catch (InterruptedException e) {
            throw new IOException2("interrupted",e);
        }
    }
View Full Code Here

    private synchronized OutputStream current() throws IOException {
        if (current==null)
            try {
                current = new FileOutputStream(out,appendOnNextOpen);
            } catch (FileNotFoundException e) {
                throw new IOException2("Failed to open "+out,e);
            }
        return current;
    }
View Full Code Here

        try {
            StringBuffer linkName = (StringBuffer) LINKNAME_FIELD.get(e);
            linkName.setLength(0);
            linkName.append(target);
        } catch (IllegalAccessException x) {
            throw new IOException2("Failed to set linkName", x);
        }

        tar.putNextEntry(e);
        entriesWritten++;
    }
View Full Code Here

            try {
                synchronized (this) {
                    this.nextBuildNumber = Integer.parseInt(f.readTrim());
                }
            } catch (NumberFormatException e) {
                throw new IOException2(f + " doesn't contain a number", e);
            }
        } else {
            // From the old Hudson, or doCreateItem. Create this file now.
            saveNextBuildNumber();
            save(); // and delete it from the config.xml
View Full Code Here

            f.delete();
            f.mkdirs();
            tmpDirectories.add(f);
            return f;
        } catch (IOException e) {
            throw new IOException2("Failed to create a temporary directory in "+base,e);
        }
    }
View Full Code Here

TOP

Related Classes of hudson.util.IOException2

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.