Search in sources :

Example 1 with Element

use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project gocd by gocd.

the class BuildLogElement method setBuildLogHeader.

public Element setBuildLogHeader(String execCommand) {
    Element target = new Element("target");
    target.setAttribute("name", "exec");
    build.addContent(target);
    buildTask = new Element("task");
    buildTask.setAttribute("name", execCommand);
    target.addContent(buildTask);
    return buildTask;
}
Also used : Element(org.jdom2.Element)

Example 2 with Element

use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project gocd by gocd.

the class BuildWork method execute.

private JobResult execute(EnvironmentVariableContext environmentVariableContext) {
    Date now = new Date();
    // collect project information
    // TODO - #2409
    buildLog.addContent(new Element("info"));
    JobResult result = builders.build(environmentVariableContext);
    goPublisher.reportCompleting(result);
    try {
        buildLog.writeLogFile(now);
    } catch (IOException e) {
        throw bomb("Failed to write log file", e);
    }
    buildLog.reset();
    return result;
}
Also used : Element(org.jdom2.Element) IOException(java.io.IOException) Date(java.util.Date)

Example 3 with Element

use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project gocd by gocd.

the class GoControlLog method writeLogFile.

/**
     * Writes the current build log to the appropriate directory and filename.
     */
public void writeLogFile(Date now) throws IOException {
    String logFilename = decideLogfileName(now);
    // Add the logDir as an info element
    Element logDirElement = new Element("property");
    logDirElement.setAttribute("name", "logdir");
    logDirElement.setAttribute("value", new File(logDir).getAbsolutePath());
    buildLog.getChild("info").addContent(logDirElement);
    // Add the logFile as an info element
    Element logFileElement = new Element("property");
    logFileElement.setAttribute("name", "logfile");
    logFileElement.setAttribute("value", logFilename);
    buildLog.getChild("info").addContent(logFileElement);
    File logfile = new File(logDir, logFilename);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Writing log file [" + logfile.getAbsolutePath() + "]");
    }
    writeLogFile(logfile, buildLog);
}
Also used : Element(org.jdom2.Element) File(java.io.File)

Example 4 with Element

use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project AnimeTaste by daimajia.

the class M3U8Mission method run.

@Override
public void run() {
    notifyStart();
    BufferedInputStream in = null;
    FileOutputStream out = null;
    HttpURLConnection httpURLConnection;
    try {
        httpURLConnection = (HttpURLConnection) new URL(getUri()).openConnection();
        in = new BufferedInputStream(httpURLConnection.getInputStream());
        out = getSafeOutputStream(getSaveDir(), getSaveName());
        mM3U8Playlist = Playlist.parse(in);
        for (Element el : mM3U8Playlist) {
            mTotalVideoDuration += el.getDuration();
        }
        mVideoSegmentCount = mM3U8Playlist.getElements().size();
        notifyMetaDataReady();
        byte[] data = new byte[1024];
        int count;
        int c = 0;
        for (Element el : mM3U8Playlist) {
            HttpURLConnection connection = (HttpURLConnection) new URL(el.getURI().toString()).openConnection();
            connection.setConnectTimeout(5000);
            in = new BufferedInputStream(connection.getInputStream());
            while (isCanceled() == false) {
                try {
                    count = in.read(data, 0, 1024);
                    if (count == -1) {
                        break;
                    }
                    out.write(data, 0, count);
                    mCurrentPartDownloaded += count;
                    mDownloaded += count;
                    notifySpeedChange();
                    checkPaused();
                } catch (Exception e) {
                    //if pause download, it will makes the socket close,and stop the download.
                    //so we need to reopen it.
                    //well, maybe a big bug here, maybe cause dead cycle :( so I set a
                    //max open count to prevent this situation.
                    mReopenCount++;
                    if (mReopenCount > MAX_REOPEN_COUNT) {
                        throw new Exception("There is too much open exception.");
                    }
                    connection = (HttpURLConnection) new URL(el.getURI().toString()).openConnection();
                    connection.setRequestProperty("Range", "bytes=" + mCurrentPartDownloaded + "-");
                    connection.setDoOutput(true);
                    connection.setDoInput(true);
                    in = new BufferedInputStream(connection.getInputStream());
                }
            }
            mCurrentPartDownloaded = 0;
            mDownloadedSgementCount++;
            mDownloadedVideoDuration += el.getDuration();
            notifyPercentageChange();
            if (isCanceled()) {
                notifyCancel();
                break;
            }
        }
        if (!isCanceled()) {
            notifyPercentageChange();
            notifySuccess();
        }
    } catch (Exception e) {
        notifyError(e);
    } finally {
        try {
            if (in != null)
                in.close();
            if (out != null)
                out.close();
        } catch (Exception e) {
            notifyError(e);
        }
        notifyFinish();
    }
}
Also used : HttpURLConnection(java.net.HttpURLConnection) BufferedInputStream(java.io.BufferedInputStream) FileOutputStream(java.io.FileOutputStream) Element(com.zhan_dui.utils.m3u8.Element) URL(java.net.URL)

Example 5 with Element

use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project pcgen by PCGen.

the class NameGenPanel method loadRuleSet.

private RuleSet loadRuleSet(Element ruleSet) throws DataConversionException {
    RuleSet rs = new RuleSet(allVars, ruleSet.getAttributeValue("title"), ruleSet.getAttributeValue("id"), ruleSet.getAttributeValue("usage"));
    java.util.List<?> elements = ruleSet.getChildren();
    ListIterator<?> elementsIterator = elements.listIterator();
    int num = 0;
    while (elementsIterator.hasNext()) {
        Element child = (Element) elementsIterator.next();
        String elementName = child.getName();
        if (elementName.equals("CATEGORY")) {
            loadCategory(child, rs);
        } else if (elementName.equals("RULE")) {
            rs.add(loadRule(child, rs.getId() + num));
        }
        num++;
    }
    return rs;
}
Also used : RuleSet(pcgen.core.doomsdaybook.RuleSet) DataElement(pcgen.core.doomsdaybook.DataElement) Element(org.jdom2.Element)

Aggregations

Element (org.jdom2.Element)829 Attribute (org.jdom2.Attribute)76 Document (org.jdom2.Document)75 Test (org.junit.Test)70 File (java.io.File)53 ArrayList (java.util.ArrayList)45 JDOMException (org.jdom2.JDOMException)37 IOException (java.io.IOException)34 HashMap (java.util.HashMap)28 NamedIcon (jmri.jmrit.catalog.NamedIcon)27 List (java.util.List)26 XmlFile (jmri.jmrit.XmlFile)24 SAXBuilder (org.jdom2.input.SAXBuilder)21 Turnout (jmri.Turnout)20 DataConversionException (org.jdom2.DataConversionException)20 DocType (org.jdom2.DocType)19 Editor (jmri.jmrit.display.Editor)18 XMLOutputter (org.jdom2.output.XMLOutputter)18 Namespace (org.jdom2.Namespace)17 Point (java.awt.Point)15