use of org.jcryptool.crypto.flexiprovider.operations.xml.ExportRootElement in project core by jcryptool.
the class OperationsManager method export.
public void export(long timestamp, String fileName) {
try {
IFileStore store = EFS.getStore(URIUtil.toURI(fileName));
OutputStream os = store.openOutputStream(SWT.NONE, null);
Document exportee = new Document(new ExportRootElement(newOperations.get(timestamp)));
new XMLOutputter(Format.getPrettyFormat()).output(exportee, os);
os.close();
} catch (CoreException e) {
LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "CoreException while exporting an operation", e, false);
} catch (IOException e) {
LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "IOException while exporting an operation", e, false);
}
}
use of org.jcryptool.crypto.flexiprovider.operations.xml.ExportRootElement in project core by jcryptool.
the class OperationsManager method importOperation.
public void importOperation(String fileName) {
try {
// $NON-NLS-1$
LogUtil.logInfo("1");
IFileStore store = EFS.getStore(URIUtil.toURI(fileName));
// $NON-NLS-1$
LogUtil.logInfo("2");
InputStream is = store.openInputStream(SWT.NONE, null);
// $NON-NLS-1$
LogUtil.logInfo("3");
SAXBuilder sax = new SAXBuilder();
// $NON-NLS-1$
LogUtil.logInfo("4");
Document doc = sax.build(is);
// $NON-NLS-1$
LogUtil.logInfo("5");
is.close();
// $NON-NLS-1$
LogUtil.logInfo("6");
ExportRootElement root = new ExportRootElement(doc.getRootElement());
// $NON-NLS-1$
LogUtil.logInfo("7");
IFlexiProviderOperation importEntry = root.getEntryNode();
// $NON-NLS-1$
LogUtil.logInfo("8");
newOperations.put(importEntry.getTimestamp(), importEntry);
// $NON-NLS-1$
LogUtil.logInfo("9");
Iterator<IOperationChangedListener> it = listeners.iterator();
while (it.hasNext()) {
it.next().addOperation();
}
// $NON-NLS-1$
LogUtil.logInfo("10");
} catch (CoreException e) {
LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "CoreException while importing an operation", e, true);
} catch (JDOMException e) {
LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "JDOMException while importing an operation", e, true);
} catch (IOException e) {
LogUtil.logError(FlexiProviderOperationsPlugin.PLUGIN_ID, "IOException while importing an operation", e, false);
}
}
Aggregations