Example usage for org.apache.commons.io FileUtils forceMkdir

List of usage examples for org.apache.commons.io FileUtils forceMkdir

Introduction

In this page you can find the example usage for org.apache.commons.io FileUtils forceMkdir.

Prototype

public static void forceMkdir(File directory) throws IOException 

Source Link

Document

Makes a directory, including any necessary but nonexistent parent directories.

Usage

From source file:de.interactive_instruments.ShapeChange.Target.Mapping.Excel.java

public void initialise(PackageInfo p, Model m, Options o, ShapeChangeResult r, boolean diagOnly)
        throws ShapeChangeAbortException {
    pi = p;/*  ww w.j  a  v a2 s .  co  m*/
    model = m;
    options = o;
    result = r;
    diagnosticsOnly = diagOnly;

    outputDirectory = options.parameter(this.getClass().getName(), "outputDirectory");
    if (outputDirectory == null)
        outputDirectory = options.parameter("outputDirectory");
    if (outputDirectory == null)
        outputDirectory = options.parameter(".");

    // change the default documentation template?
    documentationTemplate = options.parameter(this.getClass().getName(), "documentationTemplate");
    documentationNoValue = options.parameter(this.getClass().getName(), "documentationNoValue");

    // Check if we can use the output directory; create it if it
    // does not exist
    File outputDirectoryFile = new File(outputDirectory);
    boolean exi = outputDirectoryFile.exists();
    if (!exi) {
        try {
            FileUtils.forceMkdir(outputDirectoryFile);
        } catch (IOException e) {
            result.addError(null, 600, e.getMessage());
            e.printStackTrace(System.err);
        }
        exi = outputDirectoryFile.exists();
    }
    boolean dir = outputDirectoryFile.isDirectory();
    boolean wrt = outputDirectoryFile.canWrite();
    boolean rea = outputDirectoryFile.canRead();
    if (!exi || !dir || !wrt || !rea) {
        result.addFatalError(null, 601, outputDirectory);
        throw new ShapeChangeAbortException();
    }

    // FIXME correct message?
    result.addDebug(null, 10005, pi.name());

    document = createDocument();

    root = document.createElementNS(NS_SS, "Workbook");
    document.appendChild(root);
    addAttribute(document, root, "xmlns", NS_SS);
    addAttribute(document, root, "xmlns:ss", NS_SS);
    addAttribute(document, root, "xmlns:o", NS_O);
    addAttribute(document, root, "xmlns:x", NS_X);
    addAttribute(document, root, "xmlns:html", NS_HTML);

    Element e1, e2, e3;

    e1 = document.createElementNS(NS_O, "DocumentProperties");
    root.appendChild(e1);

    e2 = document.createElementNS(NS_O, "Author");
    e1.appendChild(e2);
    e2.appendChild(document.createTextNode("ShapeChange"));

    styles = document.createElementNS(NS_SS, "Styles");
    root.appendChild(styles);

    e1 = document.createElementNS(NS_SS, "Style");
    addAttribute(document, e1, "ss:ID", "Default");
    addAttribute(document, e1, "ss:Name", "Normal");
    styles.appendChild(e1);
    e2 = document.createElementNS(NS_SS, "Alignment");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Borders");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Font");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Interior");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "NumberFormat");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Protection");
    e1.appendChild(e2);

    e1 = document.createElementNS(NS_SS, "Style");
    addAttribute(document, e1, "ss:ID", "s0");
    styles.appendChild(e1);
    e2 = document.createElementNS(NS_SS, "Alignment");
    addAttribute(document, e2, "ss:Horizontal", "Center");
    addAttribute(document, e2, "ss:Vertical", "Top");
    addAttribute(document, e2, "ss:WrapText", "1");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Font");
    addAttribute(document, e2, "ss:Size", "8.0");
    e1.appendChild(e2);

    e1 = document.createElementNS(NS_SS, "Style");
    addAttribute(document, e1, "ss:ID", "s1");
    styles.appendChild(e1);
    e2 = document.createElementNS(NS_SS, "Alignment");
    addAttribute(document, e2, "ss:Horizontal", "Center");
    addAttribute(document, e2, "ss:Vertical", "Top");
    addAttribute(document, e2, "ss:WrapText", "1");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Font");
    addAttribute(document, e2, "ss:Size", "8.0");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Interior");
    addAttribute(document, e2, "ss:Color", "#FCF305");
    addAttribute(document, e2, "ss:Pattern", "Solid");
    e1.appendChild(e2);

    e1 = document.createElementNS(NS_SS, "Style");
    addAttribute(document, e1, "ss:ID", "s2");
    styles.appendChild(e1);
    e2 = document.createElementNS(NS_SS, "Alignment");
    addAttribute(document, e2, "ss:Horizontal", "Center");
    addAttribute(document, e2, "ss:Vertical", "Top");
    addAttribute(document, e2, "ss:WrapText", "1");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Borders");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Bottom");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "2");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Left");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "2");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Right");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "2");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Top");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "2");
    e2.appendChild(e3);
    e2 = document.createElementNS(NS_SS, "Font");
    addAttribute(document, e2, "ss:Size", "12.0");
    addAttribute(document, e2, "ss:Bold", "1");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Interior");
    addAttribute(document, e2, "ss:Color", "#99CCFF");
    addAttribute(document, e2, "ss:Pattern", "Solid");
    e1.appendChild(e2);

    e1 = document.createElementNS(NS_SS, "Style");
    addAttribute(document, e1, "ss:ID", "s3");
    styles.appendChild(e1);
    e2 = document.createElementNS(NS_SS, "Alignment");
    addAttribute(document, e2, "ss:Horizontal", "Center");
    addAttribute(document, e2, "ss:Vertical", "Top");
    addAttribute(document, e2, "ss:WrapText", "1");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Borders");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Bottom");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "2");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Left");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Right");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Top");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "2");
    e2.appendChild(e3);
    e2 = document.createElementNS(NS_SS, "Font");
    addAttribute(document, e2, "ss:Size", "11.0");
    addAttribute(document, e2, "ss:Bold", "1");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Interior");
    addAttribute(document, e2, "ss:Color", "#B0B0B0");
    addAttribute(document, e2, "ss:Pattern", "Solid");
    e1.appendChild(e2);

    e1 = document.createElementNS(NS_SS, "Style");
    addAttribute(document, e1, "ss:ID", "s4");
    styles.appendChild(e1);
    e2 = document.createElementNS(NS_SS, "Alignment");
    addAttribute(document, e2, "ss:Horizontal", "Left");
    addAttribute(document, e2, "ss:Vertical", "Top");
    addAttribute(document, e2, "ss:WrapText", "1");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Borders");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Bottom");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Left");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Right");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Top");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e2 = document.createElementNS(NS_SS, "Font");
    addAttribute(document, e2, "ss:Size", "10.0");
    addAttribute(document, e2, "ss:Bold", "1");
    e1.appendChild(e2);

    e1 = document.createElementNS(NS_SS, "Style");
    addAttribute(document, e1, "ss:ID", "s41");
    styles.appendChild(e1);
    e2 = document.createElementNS(NS_SS, "Alignment");
    addAttribute(document, e2, "ss:Horizontal", "Left");
    addAttribute(document, e2, "ss:Vertical", "Top");
    addAttribute(document, e2, "ss:WrapText", "1");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Borders");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Bottom");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Left");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Right");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Top");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e2 = document.createElementNS(NS_SS, "Font");
    addAttribute(document, e2, "ss:Size", "10.0");
    addAttribute(document, e2, "ss:Bold", "1");
    addAttribute(document, e2, "ss:Color", "#0000FF");
    e1.appendChild(e2);

    e1 = document.createElementNS(NS_SS, "Style");
    addAttribute(document, e1, "ss:ID", "s42");
    styles.appendChild(e1);
    e2 = document.createElementNS(NS_SS, "Alignment");
    addAttribute(document, e2, "ss:Horizontal", "Left");
    addAttribute(document, e2, "ss:Vertical", "Top");
    addAttribute(document, e2, "ss:WrapText", "1");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Borders");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Bottom");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Left");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Right");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Top");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e2 = document.createElementNS(NS_SS, "Font");
    addAttribute(document, e2, "ss:Size", "10.0");
    addAttribute(document, e2, "ss:Bold", "1");
    addAttribute(document, e2, "ss:Color", "#008080");
    e1.appendChild(e2);

    e1 = document.createElementNS(NS_SS, "Style");
    addAttribute(document, e1, "ss:ID", "s5");
    styles.appendChild(e1);
    e2 = document.createElementNS(NS_SS, "Alignment");
    addAttribute(document, e2, "ss:Horizontal", "Left");
    addAttribute(document, e2, "ss:Vertical", "Top");
    addAttribute(document, e2, "ss:WrapText", "1");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Borders");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Bottom");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Left");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Right");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Top");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e2 = document.createElementNS(NS_SS, "Font");
    addAttribute(document, e2, "ss:Size", "8.0");
    e1.appendChild(e2);

    e1 = document.createElementNS(NS_SS, "Style");
    addAttribute(document, e1, "ss:ID", "s51");
    styles.appendChild(e1);
    e2 = document.createElementNS(NS_SS, "Alignment");
    addAttribute(document, e2, "ss:Horizontal", "Left");
    addAttribute(document, e2, "ss:Vertical", "Top");
    addAttribute(document, e2, "ss:WrapText", "1");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Borders");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Bottom");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Left");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Right");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Top");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e2 = document.createElementNS(NS_SS, "Font");
    addAttribute(document, e2, "ss:Size", "8.0");
    addAttribute(document, e2, "ss:Color", "#0000FF");
    e1.appendChild(e2);

    e1 = document.createElementNS(NS_SS, "Style");
    addAttribute(document, e1, "ss:ID", "s52");
    styles.appendChild(e1);
    e2 = document.createElementNS(NS_SS, "Alignment");
    addAttribute(document, e2, "ss:Horizontal", "Left");
    addAttribute(document, e2, "ss:Vertical", "Top");
    addAttribute(document, e2, "ss:WrapText", "1");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Borders");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Bottom");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Left");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Right");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e3 = document.createElementNS(NS_SS, "Border");
    addAttribute(document, e3, "ss:Position", "Top");
    addAttribute(document, e3, "ss:LineStyle", "Continuous");
    addAttribute(document, e3, "ss:Weight", "1");
    e2.appendChild(e3);
    e2 = document.createElementNS(NS_SS, "Font");
    addAttribute(document, e2, "ss:Size", "8.0");
    addAttribute(document, e2, "ss:Color", "#008080");
    e1.appendChild(e2);

    e1 = document.createElementNS(NS_SS, "Worksheet");
    addAttribute(document, e1, "ss:Name", "Matching Table");
    root.appendChild(e1);

    table = document.createElementNS(NS_SS, "Table");
    addAttribute(document, table, "x:FullColumns", "1");
    addAttribute(document, table, "x:FullRows", "1");
    addAttribute(document, table, "ss:StyleID", "s0");
    addAttribute(document, table, "ss:DefaultRowHeight", "10.0");
    addAttribute(document, table, "ss:DefaultColumnWidth", "100.0");
    e1.appendChild(table);

    for (int i = 0; i < 7; i++) {
        e1 = document.createElementNS(NS_SS, "Column");
        addAttribute(document, e1, "ss:StyleID", "s0");
        addAttribute(document, e1, "ss:AutoFitWidth", "0");
        addAttribute(document, e1, "ss:Width", "100.0");
        table.appendChild(e1);
    }

    e1 = document.createElementNS(NS_SS, "Column");
    addAttribute(document, e1, "ss:StyleID", "s1");
    addAttribute(document, e1, "ss:AutoFitWidth", "0");
    addAttribute(document, e1, "ss:Width", "12.0");
    table.appendChild(e1);

    for (int i = 0; i < 9; i++) {
        e1 = document.createElementNS(NS_SS, "Column");
        addAttribute(document, e1, "ss:StyleID", "s0");
        addAttribute(document, e1, "ss:AutoFitWidth", "0");
        addAttribute(document, e1, "ss:Width", "100.0");
        table.appendChild(e1);
    }

    e1 = document.createElementNS(NS_SS, "Row");
    addAttribute(document, e1, "ss:AutoFitHeight", "0");
    addAttribute(document, e1, "ss:Height", "19.0");
    table.appendChild(e1);
    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:MergeAcross", "6");
    addAttribute(document, e2, "ss:StyleID", "s2");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e3.appendChild(
            document.createTextNode("Application Schema '" + pi.name() + "' (version " + pi.version() + ")"));
    e2.appendChild(e3);
    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s1");
    e1.appendChild(e2);
    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:MergeAcross", "8");
    addAttribute(document, e2, "ss:StyleID", "s2");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e3.appendChild(document.createTextNode("Application Schema <provide name of source schema>"));
    e2.appendChild(e3);

    e1 = document.createElementNS(NS_SS, "Row");
    addAttribute(document, e1, "ss:AutoFitHeight", "1");
    addAttribute(document, e1, "ss:Height", "40.0");
    table.appendChild(e1);

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);
    e3.appendChild(document.createTextNode("Type"));

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);
    e3.appendChild(document.createTextNode("Documentation"));

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);

    Element e4, e5;
    e4 = document.createElementNS(NS_HTML, "B");
    e4.appendChild(document.createTextNode("Attribute\r"));
    e5 = document.createElementNS(NS_HTML, "Font");
    addAttribute(document, e5, "html:Color", "#0000FF");
    e5.appendChild(document.createTextNode("Association role\r"));
    e4.appendChild(e5);
    e5 = document.createElementNS(NS_HTML, "Font");
    addAttribute(document, e5, "html:Color", "#008080");
    e5.appendChild(document.createTextNode("Constraint"));
    e4.appendChild(e5);
    e3.appendChild(e4);

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);

    e4 = document.createElementNS(NS_HTML, "B");
    e4.appendChild(document.createTextNode("Attribute / "));
    e5 = document.createElementNS(NS_HTML, "Font");
    addAttribute(document, e5, "html:Color", "#0000FF");
    e5.appendChild(document.createTextNode("Association role"));
    e4.appendChild(e5);
    e4.appendChild(document.createTextNode(" / "));
    e5 = document.createElementNS(NS_HTML, "Font");
    addAttribute(document, e5, "html:Color", "#008080");
    e5.appendChild(document.createTextNode("Constraint"));
    e4.appendChild(e5);
    e4.appendChild(document.createTextNode(" documentation"));
    e3.appendChild(e4);

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);
    e3.appendChild(document.createTextNode("Values / Enumerations"));

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);
    e3.appendChild(document.createTextNode("Multiplicity"));

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);
    e3.appendChild(document.createTextNode("Voidable / Non-Voidable"));

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s1");
    e1.appendChild(e2);

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);
    e3.appendChild(document.createTextNode("Type"));

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);
    e3.appendChild(document.createTextNode("Documentation"));

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);

    e4 = document.createElementNS(NS_HTML, "B");
    e4.appendChild(document.createTextNode("Attribute\r"));
    e5 = document.createElementNS(NS_HTML, "Font");
    addAttribute(document, e5, "html:Color", "#0000FF");
    e5.appendChild(document.createTextNode("Association role\r"));
    e4.appendChild(e5);
    e5 = document.createElementNS(NS_HTML, "Font");
    addAttribute(document, e5, "html:Color", "#008080");
    e5.appendChild(document.createTextNode("Constraint"));
    e4.appendChild(e5);
    e3.appendChild(e4);

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);

    e4 = document.createElementNS(NS_HTML, "B");
    e4.appendChild(document.createTextNode("Attribute / "));
    e5 = document.createElementNS(NS_HTML, "Font");
    addAttribute(document, e5, "html:Color", "#0000FF");
    e5.appendChild(document.createTextNode("Association role"));
    e4.appendChild(e5);
    e4.appendChild(document.createTextNode(" / "));
    e5 = document.createElementNS(NS_HTML, "Font");
    addAttribute(document, e5, "html:Color", "#008080");
    e5.appendChild(document.createTextNode("Constraint"));
    e4.appendChild(e5);
    e4.appendChild(document.createTextNode(" documentation"));
    e3.appendChild(e4);

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);
    e3.appendChild(document.createTextNode("Values / Enumerations"));

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);
    e3.appendChild(document.createTextNode("Multiplicity"));

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);
    e3.appendChild(document.createTextNode("Voidable / Non-Voidable"));

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);
    e3.appendChild(document.createTextNode("Status"));

    e2 = document.createElementNS(NS_SS, "Cell");
    addAttribute(document, e2, "ss:StyleID", "s3");
    e1.appendChild(e2);
    e3 = document.createElementNS(NS_SS, "Data");
    addAttribute(document, e3, "ss:Type", "String");
    e2.appendChild(e3);
    e3.appendChild(document.createTextNode("Remarks"));

}

From source file:com.vmware.appfactory.datastore.DsDatastoreCifs.java

@Override
public String createDirsIfNotExists(String... directories) throws IOException {
    _log.debug("mount path = {}", getMountPath());
    /* Create an absolute directory path */
    String path = getMountPath();
    for (String dirName : directories) {
        path = buildPath(path, dirName) + "/";
    }/*w  ww.  j av a 2  s. com*/
    _log.debug("absolute path = {}", path);
    /* Make a directory including nonexistent parent directories. */
    FileUtils.forceMkdir(new File(path));

    /* Return the full directory we just created */
    return path;
}

From source file:de.interactive_instruments.ShapeChange.Target.EA.UmlModel.java

public void initialise(PackageInfo p, Model m, Options o, ShapeChangeResult r, boolean diagOnly)
        throws ShapeChangeAbortException {

    pi = p;/*  w  ww.j av a 2 s .  c  o m*/
    model = m;
    options = o;
    result = r;

    if (!initialised) {
        initialised = true;

        String outputDirectory = options.parameter(this.getClass().getName(), PARAM_OUTPUT_DIR);
        if (outputDirectory == null)
            outputDirectory = options.parameter("outputDirectory");
        if (outputDirectory == null)
            outputDirectory = ".";

        outputFilename = options.parameter(this.getClass().getName(), "modelFilename");
        if (outputFilename == null)
            outputFilename = "ShapeChangeExport.eap";

        // change the default documentation template?
        documentationTemplate = options.parameter(this.getClass().getName(), "documentationTemplate");
        documentationNoValue = options.parameter(this.getClass().getName(), "documentationNoValue");

        /** Make sure repository file exists */
        java.io.File repfile = null;

        java.io.File outDir = new java.io.File(outputDirectory);
        if (!outDir.exists()) {
            try {
                FileUtils.forceMkdir(outDir);
            } catch (IOException e) {
                String errormsg = e.getMessage();
                r.addError(null, 32, errormsg, outputDirectory);
                return;
            }
        }

        repfile = new java.io.File(outDir, outputFilename);

        boolean ex = true;

        rep = new Repository();

        if (!repfile.exists()) {
            ex = false;
            if (!outputFilename.toLowerCase().endsWith(".eap")) {
                outputFilename += ".eap";
                repfile = new java.io.File(outputFilename);
                ex = repfile.exists();
            }
        }

        String absname = repfile.getAbsolutePath();

        if (!ex) {
            if (!rep.CreateModel(CreateModelType.cmEAPFromBase, absname, 0)) {
                r.addError(null, 31, absname);
                rep = null;
                return;
            }
        }

        /** Connect to EA Repository */
        if (!rep.OpenFile(absname)) {
            String errormsg = rep.GetLastError();
            r.addError(null, 30, errormsg, outputFilename);
            rep = null;
            return;
        }

        rep.RefreshModelView(0);

        Collection<Package> c = rep.GetModels();
        Package root = c.GetAt((short) 0);

        TimeZone tz = TimeZone.getTimeZone("UTC");
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
        df.setTimeZone(tz);

        Package pOut = root.GetPackages().AddNew("ShapeChangeOutput-" + df.format(new Date()), "Class View");
        if (!pOut.Update()) {
            result.addError("EA-Fehler: " + pOut.GetLastError());
        }
        pOut_EaPkgId = pOut.GetPackageID();
    }

    if (rep == null || pOut_EaPkgId == null)
        return; // repository not initialised

    // export app schema package
    clonePackage(pi, pOut_EaPkgId);
}

From source file:com.opengamma.integration.timeseries.snapshot.RedisLKVFileWriter.java

private void ensureParentDirectory(final File outputFile) {
    try {//from  www  .j  a v a  2 s .  com
        s_logger.debug("creating directory {}", outputFile.getParent());
        FileUtils.forceMkdir(outputFile.getParentFile());
        s_logger.debug("directory created");
    } catch (IOException ex) {
        throw new OpenGammaRuntimeException("Error creating directory " + outputFile.getParent(), ex);
    }
}

From source file:hoot.services.controllers.ingest.FileUploadResourceTest.java

@Test
@Category(UnitTest.class)
public void TestCreateNativeRequestFgdbOgrZip() throws Exception {
    String input = "fgdb_ogr.zip";
    String jobId = "test-id-123";
    String wkdirpath = homeFolder + "/upload/" + jobId;
    File workingDir = new File(wkdirpath);
    FileUtils.forceMkdir(workingDir);
    org.junit.Assert.assertTrue(workingDir.exists());

    File srcFile = new File(homeFolder + "/test-files/service/FileUploadResourceTest/" + input);
    File destFile = new File(wkdirpath + "/" + input);
    FileUtils.copyFile(srcFile, destFile);
    org.junit.Assert.assertTrue(destFile.exists());

    FileUploadResource res = new FileUploadResource();

    // Let's test zip
    JSONArray results = new JSONArray();
    JSONObject zipStat = new JSONObject();
    List<String> inputsList = new ArrayList<String>();
    inputsList.add(input);/*from w  w w.  ja v  a 2 s.  c o m*/

    res._buildNativeRequest(jobId, "fgdb_ogr", "zip", input, results, zipStat);

    int shpCnt = 0;
    int osmCnt = 0;
    int fgdbCnt = 0;

    int zipCnt = 0;
    int shpZipCnt = 0;
    int osmZipCnt = 0;
    int fgdbZipCnt = 0;
    List<String> zipList = new ArrayList<String>();

    shpZipCnt += (Integer) zipStat.get("shpzipcnt");
    fgdbZipCnt += (Integer) zipStat.get("fgdbzipcnt");
    osmZipCnt += (Integer) zipStat.get("osmzipcnt");

    zipList.add("fgdb_ogr");
    zipCnt++;

    // Test zip containing fgdb + shp
    JSONArray resA = res._createNativeRequest(results, zipCnt, shpZipCnt, fgdbZipCnt, osmZipCnt, shpCnt,
            fgdbCnt, osmCnt, zipList, "TDSv61.js", jobId, "fgdb_ogr", inputsList);

    JSONObject req = (JSONObject) resA.get(0);
    JSONArray params = (JSONArray) req.get("params");

    int nP = 0;

    for (Object o : params) {
        JSONObject oJ = (JSONObject) o;

        if (oJ.get("INPUT") != null) {
            org.junit.Assert.assertTrue(oJ.get("INPUT").toString()
                    .equals("\"fgdb_ogr/DcGisRoads.gdb\" \"fgdb_ogr/jakarta_raya_coastline.shp\" "));
            nP++;
        }

        if (oJ.get("INPUT_PATH") != null) {
            org.junit.Assert.assertTrue(oJ.get("INPUT_PATH").toString().equals("upload/test-id-123"));
            nP++;
        }

        if (oJ.get("INPUT_TYPE") != null) {
            org.junit.Assert.assertTrue(oJ.get("INPUT_TYPE").toString().equals("OGR"));
            nP++;
        }

        if (oJ.get("UNZIP_LIST") != null) {
            org.junit.Assert.assertTrue(oJ.get("UNZIP_LIST").toString().equals("fgdb_ogr"));
            nP++;
        }
    }
    org.junit.Assert.assertTrue(nP == 4);
    FileUtils.forceDelete(workingDir);
}

From source file:com.google.gdt.eclipse.designer.core.model.widgets.ClassLoaderTest.java

/**
 * We should make sure that we support parsing for Maven projects.
 *//* w w w  .ja  v  a  2 s .co  m*/
@DisposeProjectAfter
public void test_gwtInMavenStructure() throws Exception {
    // remove existing GWT jars from classpath
    ProjectUtils.removeClasspathEntries(m_javaProject, new Predicate<IClasspathEntry>() {
        @Override
        public boolean apply(IClasspathEntry entry) {
            return entry.getPath().toPortableString().contains("gwt-");
        }
    });
    // prepare Maven-like structure
    File userFile;
    File devFile;
    {
        String testLocation = Activator.getDefault().getStateLocation().toPortableString();
        File gwtDirectory = new File(testLocation + "/SDK from Maven");
        // prepare locations
        userFile = new File(gwtDirectory + "/gwt/gwt-user/2.2.0/gwt-user-2.2.0.jar");
        devFile = new File(gwtDirectory + "/gwt/gwt-dev/2.2.0/gwt-dev-2.2.0.jar");
        FileUtils.forceMkdir(userFile.getParentFile());
        FileUtils.forceMkdir(devFile.getParentFile());
        // copy jars
        String sdkLocation = getGWTLocation_forProject();
        FileUtils.copyFile(new File(sdkLocation + "/gwt-user.jar"), userFile, false);
        FileUtils.copyFile(new File(sdkLocation + "/gwt-dev.jar"), devFile, false);
        // use this gwt-user.jar
        ProjectUtils.addExternalJar(m_javaProject, userFile.getAbsolutePath(), null);
        m_project.refreshLocal(IResource.DEPTH_INFINITE, null);
    }
    // try parse
    try {
        parseJavaInfo("// filler filler filler filler filler", "public class Test extends FlowPanel {",
                "  public Test() {", "  }", "}");
    } finally {
        makeGwtJarEmpty(userFile);
        makeGwtJarEmpty(devFile);
    }
}

From source file:de.egore911.versioning.deployer.performer.PerformExtraction.java

private static boolean extract(String uri, List<ExtractionPair> extractions) {
    URL url;/*from   w w  w . ja  v a2 s  . com*/
    try {
        url = new URL(uri);
    } catch (MalformedURLException e) {
        LOG.error("Invalid URI: {}", e.getMessage(), e);
        return false;
    }
    try {
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        int response = connection.getResponseCode();

        int lastSlash = uri.lastIndexOf('/');
        if (lastSlash < 0) {
            LOG.error("Invalid URI: {}", uri);
            return false;
        }

        int lastDot = uri.lastIndexOf('.');
        if (lastDot < 0) {
            LOG.error("Invalid URI: {}", uri);
            return false;
        }

        File downloadFile = File.createTempFile(uri.substring(lastSlash + 1), uri.substring(lastDot + 1));
        downloadFile.deleteOnExit();

        if (response == HttpURLConnection.HTTP_OK) {
            try (InputStream in = connection.getInputStream();
                    FileOutputStream out = new FileOutputStream(downloadFile)) {
                IOUtils.copy(in, out);
            }
            LOG.debug("Downloaded {} to {}", url, downloadFile.getAbsolutePath());

            Set<ExtractionPair> usedExtractions = new HashSet<>();

            // Perform extractions
            try (ZipFile zipFile = new ZipFile(downloadFile)) {
                Enumeration<? extends ZipEntry> entries = zipFile.entries();
                while (entries.hasMoreElements()) {
                    ZipEntry entry = entries.nextElement();

                    // Only extract files
                    if (entry.isDirectory()) {
                        continue;
                    }

                    for (ExtractionPair extraction : extractions) {
                        String sourcePattern = extraction.source;
                        if (FilenameUtils.wildcardMatch(entry.getName(), sourcePattern)) {
                            usedExtractions.add(extraction);
                            LOG.debug("Found matching file {} for source pattern {}", entry.getName(),
                                    sourcePattern);
                            String filename = getSourcePatternMatch(entry.getName(), sourcePattern);
                            // Workaround: If there is no matcher in 'sourcePattern' it will return the
                            // complete path. Strip it down to the filename
                            if (filename.equals(entry.getName())) {
                                int lastIndexOf = filename.lastIndexOf('/');
                                if (lastIndexOf >= 0) {
                                    filename = filename.substring(lastIndexOf + 1);
                                }
                            }
                            String name = UrlUtil.concatenateUrlWithSlashes(extraction.destination, filename);
                            FileUtils.forceMkdir(new File(name).getParentFile());
                            try (InputStream in = zipFile.getInputStream(entry);
                                    FileOutputStream out = new FileOutputStream(name)) {
                                IOUtils.copy(in, out);
                            }
                            LOG.debug("Extracted {} to {} from {}", entry.getName(), name, uri);
                        }
                    }
                }
            }

            for (ExtractionPair extraction : extractions) {
                if (!usedExtractions.contains(extraction)) {
                    LOG.debug("Extraction {} to {} not used on {}", extraction.source, extraction.destination,
                            uri);
                }
            }

            return true;
        } else {
            LOG.error("Could not download file: {}", uri);
            return false;
        }
    } catch (IOException e) {
        LOG.error("Could not download file: {}", e.getMessage(), e);
        return false;
    }
}

From source file:com.alibaba.otter.node.etl.common.pipe.impl.http.archive.ArchiveBean.java

/**
 * /*from  ww  w  . j a  v  a 2s .co  m*/
 */
@SuppressWarnings("resource")
private boolean doPack(final File targetArchiveFile, List<FileData> fileDatas,
        final ArchiveRetriverCallback<FileData> callback) {
    // ?
    if (true == targetArchiveFile.exists() && false == NioUtils.delete(targetArchiveFile, 3)) {
        throw new ArchiveException(
                String.format("[%s] exist and delete failed", targetArchiveFile.getAbsolutePath()));
    }

    boolean exist = false;
    ZipOutputStream zipOut = null;
    Set<String> entryNames = new HashSet<String>();
    BlockingQueue<Future<ArchiveEntry>> queue = new LinkedBlockingQueue<Future<ArchiveEntry>>(); // ?
    ExecutorCompletionService completionService = new ExecutorCompletionService(executor, queue);

    final File targetDir = new File(targetArchiveFile.getParentFile(),
            FilenameUtils.getBaseName(targetArchiveFile.getPath()));
    try {
        // 
        FileUtils.forceMkdir(targetDir);

        zipOut = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(targetArchiveFile)));
        zipOut.setLevel(Deflater.BEST_SPEED);
        // ??
        for (final FileData fileData : fileDatas) {
            if (fileData.getEventType().isDelete()) {
                continue; // delete??
            }

            String namespace = fileData.getNameSpace();
            String path = fileData.getPath();
            boolean isLocal = StringUtils.isBlank(namespace);
            String entryName = null;
            if (true == isLocal) {
                entryName = FilenameUtils.getPath(path) + FilenameUtils.getName(path);
            } else {
                entryName = namespace + File.separator + path;
            }

            // ????
            if (entryNames.contains(entryName) == false) {
                entryNames.add(entryName);
            } else {
                continue;
            }

            final String name = entryName;
            if (true == isLocal && !useLocalFileMutliThread) {
                // ??
                queue.add(new DummyFuture(new ArchiveEntry(name, callback.retrive(fileData))));
            } else {
                completionService.submit(new Callable<ArchiveEntry>() {

                    public ArchiveEntry call() throws Exception {
                        // ??
                        InputStream input = null;
                        OutputStream output = null;
                        try {
                            input = callback.retrive(fileData);

                            if (input instanceof LazyFileInputStream) {
                                input = ((LazyFileInputStream) input).getInputSteam();// ?stream
                            }

                            if (input != null) {
                                File tmp = new File(targetDir, name);
                                NioUtils.create(tmp.getParentFile(), false, 3);// ?
                                output = new FileOutputStream(tmp);
                                NioUtils.copy(input, output);// ?
                                return new ArchiveEntry(name, new File(targetDir, name));
                            } else {
                                return new ArchiveEntry(name);
                            }
                        } finally {
                            IOUtils.closeQuietly(input);
                            IOUtils.closeQuietly(output);
                        }
                    }
                });
            }
        }

        for (int i = 0; i < entryNames.size(); i++) {
            // ?
            ArchiveEntry input = null;
            InputStream stream = null;
            try {
                input = queue.take().get();
                if (input == null) {
                    continue;
                }

                stream = input.getStream();
                if (stream == null) {
                    continue;
                }

                if (stream instanceof LazyFileInputStream) {
                    stream = ((LazyFileInputStream) stream).getInputSteam();// ?stream
                }

                exist = true;
                zipOut.putNextEntry(new ZipEntry(input.getName()));
                NioUtils.copy(stream, zipOut);// ?
                zipOut.closeEntry();
            } finally {
                IOUtils.closeQuietly(stream);
            }
        }

        if (exist) {
            zipOut.finish();
        }
    } catch (Exception e) {
        throw new ArchiveException(e);
    } finally {
        IOUtils.closeQuietly(zipOut);
        try {
            FileUtils.deleteDirectory(targetDir);// 
        } catch (IOException e) {
            // ignore
        }
    }

    return exist;
}

From source file:net.sourceforge.atunes.kernel.modules.audioscrobbler.AudioScrobblerCache.java

/**
 * Private getter for albumCoverCacheDir. If dir does not exist, it's
 * created/* w w w .j a  va  2 s .  com*/
 * 
 * @return
 * @throws IOException
 */
private static synchronized File getAlbumCoverCacheDir() throws IOException {
    if (!albumCoverCacheDir.exists())
        FileUtils.forceMkdir(albumCoverCacheDir);
    return albumCoverCacheDir;
}

From source file:com.orange.mmp.dao.flf.MidletDaoFlfImpl.java

@Override
public void checkDaoConfig() throws MMPDaoException {
    if (this.path == null)
        throw new MMPDaoException("Missing Path for Midlet DAO FLF configuration");
    File file = new File(this.path);
    if (!file.exists()) {
        try {//from   w  w  w .j  a  va  2 s. co m
            FileUtils.forceMkdir(file);
        } catch (IOException ioe) {
            throw new MMPDaoException("Failed to create Midlet DAO FLF folder : " + ioe.getMessage());
        }
    } else if (!file.isDirectory()) {
        throw new MMPDaoException("Path used for Midlet DAO FLF must be a directory");
    }
}