Search in sources :

Example 1 with OperationsViewEntryRootElement

use of org.jcryptool.crypto.flexiprovider.operations.xml.OperationsViewEntryRootElement in project core by jcryptool.

the class OperationsManager method saveXML.

public void saveXML() {
    FileOutputStream fos;
    try {
        root = new OperationsViewEntryRootElement();
        Iterator<IFlexiProviderOperation> it = newOperations.values().iterator();
        while (it.hasNext()) {
            root.addEntry(it.next());
        }
        document = new Document(root);
        fos = new FileOutputStream(operationsFile);
        new XMLOutputter(Format.getPrettyFormat()).output(document, fos);
    } catch (FileNotFoundException e) {
        LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "FileNotFoundException while attempting to write the operations.xml file", e, true);
    } catch (IOException e) {
        LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "IOException while attempting to write the operations.xml file", e, true);
    }
}
Also used : XMLOutputter(org.jdom.output.XMLOutputter) FileOutputStream(java.io.FileOutputStream) OperationsViewEntryRootElement(org.jcryptool.crypto.flexiprovider.operations.xml.OperationsViewEntryRootElement) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) Document(org.jdom.Document) IFlexiProviderOperation(org.jcryptool.crypto.flexiprovider.descriptors.IFlexiProviderOperation)

Example 2 with OperationsViewEntryRootElement

use of org.jcryptool.crypto.flexiprovider.operations.xml.OperationsViewEntryRootElement in project core by jcryptool.

the class OperationsManager method loadOperations.

private static void loadOperations() {
    File flexiprovider = new File(DirectoryService.getWorkspaceDir(), FLEXIPROVIDER_FOLDER);
    if (!flexiprovider.exists()) {
        flexiprovider.mkdir();
    }
    operationsFile = new File(flexiprovider, OPERATIONS_FILE_NAME);
    if (operationsFile != null && operationsFile.exists() && !loaded) {
        // ensure FlexiProvider is initialized
        ProviderManager2.getInstance();
        // load xml structure
        document = loadXML();
        if (document != null) {
            root = new OperationsViewEntryRootElement(document.getRootElement());
            Iterator<EntryNode> it = root.getEntryNodes().iterator();
            while (it.hasNext()) {
                IFlexiProviderOperation current = it.next();
                newOperations.put(current.getTimestamp(), current);
            }
            loaded = true;
        }
    }
}
Also used : OperationsViewEntryRootElement(org.jcryptool.crypto.flexiprovider.operations.xml.OperationsViewEntryRootElement) EntryNode(org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode) File(java.io.File) IFlexiProviderOperation(org.jcryptool.crypto.flexiprovider.descriptors.IFlexiProviderOperation)

Aggregations

IFlexiProviderOperation (org.jcryptool.crypto.flexiprovider.descriptors.IFlexiProviderOperation)2 OperationsViewEntryRootElement (org.jcryptool.crypto.flexiprovider.operations.xml.OperationsViewEntryRootElement)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 EntryNode (org.jcryptool.crypto.flexiprovider.operations.ui.views.nodes.EntryNode)1 Document (org.jdom.Document)1 XMLOutputter (org.jdom.output.XMLOutputter)1