Search in sources :

Example 81 with Attribute

use of com.mindbright.security.x509.Attribute in project s1tbx by senbox-org.

the class BinaryDBReader method DecodeElement.

private static void DecodeElement(final BinaryFileReader reader, final Map metaMap, final Element child, final String suffix) {
    String name = "";
    try {
        final Attribute nameAttrib = child.getAttribute("name");
        final Attribute typeAttrib = child.getAttribute("type");
        final Attribute numAttrib = child.getAttribute("num");
        if (nameAttrib != null && typeAttrib != null && numAttrib != null) {
            name = nameAttrib.getValue();
            if (suffix != null)
                name += suffix;
            final int type = Integer.parseInt(typeAttrib.getValue());
            final int num = Integer.parseInt(numAttrib.getValue());
            switch(type) {
                case Skip:
                    {
                        // blank
                        reader.skipBytes(num);
                        break;
                    }
                case An:
                    {
                        metaMap.put(name, reader.readAn(num));
                        break;
                    }
                case In:
                    {
                        metaMap.put(name, (int) reader.readIn(num));
                        break;
                    }
                case B1:
                    {
                        metaMap.put(name, reader.readB1());
                        break;
                    }
                case B2:
                    {
                        metaMap.put(name, reader.readB2());
                        break;
                    }
                case B4:
                    {
                        metaMap.put(name, reader.readB4());
                        break;
                    }
                case B8:
                    {
                        metaMap.put(name, reader.readB8());
                        break;
                    }
                case Fn:
                    {
                        metaMap.put(name, reader.readFn(num));
                        break;
                    }
                case En:
                    {
                        metaMap.put(name, reader.readEn(num));
                        break;
                    }
                case Debug:
                    {
                        System.out.print(" = ");
                        for (int i = 0; i < num; ++i) {
                            final String tmp = reader.readAn(1);
                            if (!tmp.isEmpty() && !tmp.equals(" "))
                                System.out.print(tmp);
                        }
                        System.out.println();
                        break;
                    }
                default:
                    {
                        throw new IllegalBinaryFormatException("Unknown type " + type, reader.getCurrentPos());
                    }
            }
        }
    } catch (Exception e) {
        if (e.getCause() != null)
            SystemUtils.LOG.severe(' ' + e.toString() + ':' + e.getCause().toString() + " for " + name);
        else
            SystemUtils.LOG.severe(' ' + e.toString() + ':' + " for " + name);
    }
}
Also used : Attribute(org.jdom2.Attribute) MetadataAttribute(org.esa.snap.core.datamodel.MetadataAttribute) IOException(java.io.IOException)

Example 82 with Attribute

use of com.mindbright.security.x509.Attribute in project s1tbx by senbox-org.

the class BinaryDBReader method DecodeElementDebug.

private void DecodeElementDebug(final BinaryFileReader reader, final Map metaMap, final Element child, final String suffix) {
    String name = "";
    try {
        final Attribute nameAttrib = child.getAttribute("name");
        final Attribute typeAttrib = child.getAttribute("type");
        final Attribute numAttrib = child.getAttribute("num");
        if (nameAttrib != null && typeAttrib != null && numAttrib != null) {
            name = nameAttrib.getValue();
            if (suffix != null)
                name += suffix;
            final int type = Integer.parseInt(typeAttrib.getValue());
            final int num = Integer.parseInt(numAttrib.getValue());
            System.out.print(" " + reader.getCurrentPos() + ' ' + (reader.getCurrentPos() - startPos + 1) + ' ' + name + ' ' + type + ' ' + num);
            switch(type) {
                case Skip:
                    {
                        // blank
                        reader.skipBytes(num);
                        break;
                    }
                case An:
                    {
                        final String tmp = reader.readAn(num);
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case In:
                    {
                        final int tmp = (int) reader.readIn(num);
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case B1:
                    {
                        final int tmp = reader.readB1();
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case B2:
                    {
                        final int tmp = reader.readB2();
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case B4:
                    {
                        final int tmp = reader.readB4();
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case B8:
                    {
                        final long tmp = reader.readB8();
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case Fn:
                    {
                        double tmp = reader.readFn(num);
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case En:
                    {
                        double tmp = reader.readEn(num);
                        System.out.print(" = " + tmp);
                        metaMap.put(name, tmp);
                        break;
                    }
                case Debug:
                    {
                        System.out.print(" = ");
                        for (int i = 0; i < num; ++i) {
                            final String tmp = reader.readAn(1);
                            if (!tmp.isEmpty() && !tmp.equals(" "))
                                System.out.print(tmp);
                        }
                        System.out.println();
                        break;
                    }
                default:
                    {
                        throw new IllegalBinaryFormatException("Unknown type " + type, reader.getCurrentPos());
                    }
            }
            System.out.println();
        }
    } catch (Exception e) {
        if (e.getCause() != null)
            SystemUtils.LOG.severe(' ' + e.toString() + ':' + e.getCause().toString() + " for " + name);
        else
            SystemUtils.LOG.severe(' ' + e.toString() + ':' + " for " + name);
    // throw new IllegalBinaryFormatException(e.toString(), reader.getCurrentPos());
    }
}
Also used : Attribute(org.jdom2.Attribute) MetadataAttribute(org.esa.snap.core.datamodel.MetadataAttribute) IOException(java.io.IOException)

Example 83 with Attribute

use of com.mindbright.security.x509.Attribute in project s1tbx by senbox-org.

the class NetCDFUtils method addAttributes.

public static MetadataElement addAttributes(final MetadataElement parentElem, final String elemName, final List<Attribute> attribList) {
    final MetadataElement globalElem = new MetadataElement(elemName);
    parentElem.addElement(globalElem);
    for (Attribute at : attribList) {
        createMetadataAttributes(globalElem, at, at.getName());
    }
    return globalElem;
}
Also used : Attribute(ucar.nc2.Attribute) MetadataAttribute(org.esa.snap.core.datamodel.MetadataAttribute) MetadataElement(org.esa.snap.core.datamodel.MetadataElement)

Example 84 with Attribute

use of com.mindbright.security.x509.Attribute in project kitodo-production by kitodo.

the class ExportXmlLog method startMultipleExport.

/**
 * This method exports the production metadata for al list of processes as a
 * single file to a given stream.
 *
 * @param docketDataList
 *            a list of Docket data
 * @param outputStream
 *            The output stream, to write the docket to.
 */
void startMultipleExport(Iterable<DocketData> docketDataList, OutputStream outputStream) {
    Document answer = new Document();
    Element root = new Element("processes");
    answer.setRootElement(root);
    Namespace xmlns = Namespace.getNamespace(NAMESPACE);
    Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
    root.addNamespaceDeclaration(xsi);
    root.setNamespace(xmlns);
    Attribute attSchema = new Attribute("schemaLocation", NAMESPACE + " XML-logfile.xsd", xsi);
    root.setAttribute(attSchema);
    for (DocketData docketData : docketDataList) {
        Document doc = createDocument(docketData, false);
        Element processRoot = doc.getRootElement();
        processRoot.detach();
        root.addContent(processRoot);
    }
    XMLOutputter outp = new XMLOutputter(Format.getPrettyFormat());
    try {
        outp.output(answer, outputStream);
    } catch (IOException e) {
        logger.error("Generating XML Output failed.", e);
    } finally {
        if (outputStream != null) {
            try {
                outputStream.close();
            } catch (IOException e) {
                logger.error("Closing the output stream failed.", e);
            }
        }
    }
}
Also used : XMLOutputter(org.jdom2.output.XMLOutputter) Attribute(org.jdom2.Attribute) DocketData(org.kitodo.api.docket.DocketData) Element(org.jdom2.Element) IOException(java.io.IOException) Document(org.jdom2.Document) Namespace(org.jdom2.Namespace)

Example 85 with Attribute

use of com.mindbright.security.x509.Attribute in project kitodo-production by kitodo.

the class ExportXmlLog method createDocument.

/**
 * This method creates a new xml document with process metadata.
 *
 * @param docketData
 *            the docketData to export
 * @return a new xml document
 */
private Document createDocument(DocketData docketData, boolean addNamespace) {
    Element processElm = new Element("process");
    final Document doc = new Document(processElm);
    processElm.setAttribute("processID", String.valueOf(docketData.getProcessId()));
    Namespace xmlns = Namespace.getNamespace(NAMESPACE);
    processElm.setNamespace(xmlns);
    // namespace declaration
    if (addNamespace) {
        Namespace xsi = Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
        processElm.addNamespaceDeclaration(xsi);
        Attribute attSchema = new Attribute("schemaLocation", NAMESPACE + " XML-logfile.xsd", xsi);
        processElm.setAttribute(attSchema);
    }
    // process information
    ArrayList<Element> processElements = new ArrayList<>();
    Element processTitle = new Element("title", xmlns);
    processTitle.setText(docketData.getProcessName());
    processElements.add(processTitle);
    Element project = new Element("project", xmlns);
    project.setText(docketData.getProjectName());
    processElements.add(project);
    Element date = new Element("time", xmlns);
    date.setAttribute("type", "creation date");
    date.setText(String.valueOf(docketData.getCreationDate()));
    processElements.add(date);
    Element ruleset = new Element("ruleset", xmlns);
    ruleset.setText(docketData.getRulesetName());
    processElements.add(ruleset);
    Element comment = new Element("comment", xmlns);
    comment.setText(docketData.getComment());
    processElements.add(comment);
    List<Element> processProperties = prepareProperties(docketData.getProcessProperties(), xmlns);
    if (!processProperties.isEmpty()) {
        Element properties = new Element(PROPERTIES, xmlns);
        properties.addContent(processProperties);
        processElements.add(properties);
    }
    // template information
    ArrayList<Element> templateElements = new ArrayList<>();
    Element template = new Element("original", xmlns);
    ArrayList<Element> templateProperties = new ArrayList<>();
    if (docketData.getTemplateProperties() != null) {
        for (Property prop : docketData.getTemplateProperties()) {
            Element property = new Element(PROPERTY, xmlns);
            property.setAttribute(PROPERTY_IDENTIFIER, prop.getTitle());
            if (prop.getValue() != null) {
                property.setAttribute(VALUE, replacer(prop.getValue()));
            } else {
                property.setAttribute(VALUE, "");
            }
            Element label = new Element(LABEL, xmlns);
            label.setText(prop.getTitle());
            property.addContent(label);
            templateProperties.add(property);
            if (prop.getTitle().equals("Signatur")) {
                Element secondProperty = new Element(PROPERTY, xmlns);
                secondProperty.setAttribute(PROPERTY_IDENTIFIER, prop.getTitle() + "Encoded");
                if (prop.getValue() != null) {
                    secondProperty.setAttribute(VALUE, "vorl:" + replacer(prop.getValue()));
                    Element secondLabel = new Element(LABEL, xmlns);
                    secondLabel.setText(prop.getTitle());
                    secondProperty.addContent(secondLabel);
                    templateProperties.add(secondProperty);
                }
            }
        }
    }
    if (!templateProperties.isEmpty()) {
        Element properties = new Element(PROPERTIES, xmlns);
        properties.addContent(templateProperties);
        template.addContent(properties);
    }
    templateElements.add(template);
    Element templates = new Element("originals", xmlns);
    templates.addContent(templateElements);
    processElements.add(templates);
    // digital document information
    ArrayList<Element> docElements = new ArrayList<>();
    Element dd = new Element("digitalDocument", xmlns);
    List<Element> docProperties = prepareProperties(docketData.getWorkpieceProperties(), xmlns);
    if (!docProperties.isEmpty()) {
        Element properties = new Element(PROPERTIES, xmlns);
        properties.addContent(docProperties);
        dd.addContent(properties);
    }
    docElements.add(dd);
    Element digdoc = new Element("digitalDocuments", xmlns);
    digdoc.addContent(docElements);
    processElements.add(digdoc);
    processElm.setContent(processElements);
    return doc;
}
Also used : Attribute(org.jdom2.Attribute) Element(org.jdom2.Element) ArrayList(java.util.ArrayList) Document(org.jdom2.Document) Property(org.kitodo.api.docket.Property) Namespace(org.jdom2.Namespace)

Aggregations

Attribute (org.jdom2.Attribute)316 Element (org.jdom2.Element)210 Attribute (ucar.nc2.Attribute)65 IOException (java.io.IOException)55 ArrayList (java.util.ArrayList)51 Document (org.jdom2.Document)43 Variable (ucar.nc2.Variable)39 List (java.util.List)31 HashMap (java.util.HashMap)25 Namespace (org.jdom2.Namespace)24 File (java.io.File)21 Array (ucar.ma2.Array)21 DataConversionException (org.jdom2.DataConversionException)19 Test (org.junit.Test)19 Dimension (ucar.nc2.Dimension)19 Map (java.util.Map)17 JDOMException (org.jdom2.JDOMException)16 XmlDslUtils.addMigrationAttributeToElement (com.mulesoft.tools.migration.step.util.XmlDslUtils.addMigrationAttributeToElement)15 Editor (jmri.jmrit.display.Editor)15 NamedIcon (jmri.jmrit.catalog.NamedIcon)13