use of javax.xml.parsers.ParserConfigurationException in project tdi-studio-se by Talend.
the class Snapshot method getTimeStamp.
/*
* @see ISnapshot#getTimeStamp()
*/
@Override
public String getTimeStamp() {
if (timeStamp != null) {
return timeStamp;
}
if (snapshotType == SnapshotType.Hprof) {
long lastModified = fileStore.fetchInfo().getLastModified();
if (lastModified == EFS.NONE) {
return null;
}
Date currentDate = new Date(lastModified);
//$NON-NLS-1$
String date = new SimpleDateFormat("yyyy/MM/dd").format(currentDate);
//$NON-NLS-1$
String time = new SimpleDateFormat("HH:mm:ss").format(currentDate);
//$NON-NLS-1$
timeStamp = date + " " + time;
return timeStamp;
}
InputStream inputStream = null;
try {
inputStream = new FileInputStream(new File(fileStore.toURI().getPath()));
Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream);
Element root = document.getDocumentElement();
//$NON-NLS-1$
timeStamp = root.getAttribute("date");
return timeStamp;
} catch (SAXException e) {
Activator.log(IStatus.ERROR, NLS.bind(Messages.readFileFailedMsg, fileStore.toURI().getPath()), e);
} catch (IOException e) {
Activator.log(IStatus.ERROR, NLS.bind(Messages.readFileFailedMsg, fileStore.toURI().getPath()), e);
} catch (ParserConfigurationException e) {
Activator.log(IStatus.ERROR, NLS.bind(Messages.readFileFailedMsg, fileStore.toURI().getPath()), e);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
// ignore
}
}
}
return null;
}
use of javax.xml.parsers.ParserConfigurationException in project tdi-studio-se by Talend.
the class HeapDumpEditor method parseDumpFile.
/**
* Parses the dump file.
*
* @param filePath The file path
*/
private void parseDumpFile(final String filePath) {
Job job = new Job(Messages.parseHeapDumpFileJobLabel) {
@Override
protected IStatus run(IProgressMonitor monitor) {
HeapDumpParser parser = new HeapDumpParser(new File(filePath), heapListElements, monitor);
try {
parser.parse();
} catch (ParserConfigurationException e) {
//$NON-NLS-1$
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not load heap dump file.", e);
} catch (SAXException e) {
//$NON-NLS-1$
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not load heap dump file.", e);
} catch (IOException e) {
//$NON-NLS-1$
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Could not load heap dump file.", e);
}
setProfileInfo(parser.getProfileInfo());
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
if (heapHistogramPage != null) {
heapHistogramPage.refresh();
}
}
});
return Status.OK_STATUS;
}
};
job.schedule();
}
use of javax.xml.parsers.ParserConfigurationException in project tdi-studio-se by Talend.
the class ExpressionBuilderDialog method createButtonsForButtonBar.
/**
* Create contents of the button bar
*
* @param parent
*/
@Override
protected void createButtonsForButtonBar(Composite parent) {
((GridLayout) parent.getLayout()).numColumns++;
Composite buttons = new Composite(parent, SWT.NONE);
buttons.setLayout(new GridLayout(2, false));
final Button importButton = new Button(buttons, SWT.PUSH);
//$NON-NLS-1$
importButton.setToolTipText(Messages.getString("ExpressionBuilderDialog.import"));
importButton.setImage(ImageProvider.getImage(EImage.IMPORT_ICON));
final Button exportButton = new Button(buttons, SWT.PUSH);
//$NON-NLS-1$
exportButton.setToolTipText(Messages.getString("ExpressionBuilderDialog.export"));
exportButton.setImage(ImageProvider.getImage(EImage.EXPORT_ICON));
//$NON-NLS-1$
createButton(parent, IDialogConstants.OK_ID, Messages.getString("ExpressionBuilderDialog.ok.button"), true);
//$NON-NLS-1$
createButton(parent, IDialogConstants.CANCEL_ID, Messages.getString("ExpressionBuilderDialog.cancel.button"), false);
exportButton.addMouseListener(new MouseAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseUp(MouseEvent e) {
FileDialog dialog = new FileDialog(getShell(), SWT.SAVE);
//$NON-NLS-1$
dialog.setFilterExtensions(new String[] { "*.xml" });
String filePath = dialog.open();
if (filePath != null) {
String expresionContent = expressionComposite.getExpression();
List<Variable> variables = new ArrayList<Variable>();
variables = testComposite.getVariableList();
File file = new File(filePath);
ExpressionFileOperation operation = new ExpressionFileOperation();
try {
if (file != null) {
file.createNewFile();
}
operation.saveExpressionToFile(file, variables, expresionContent);
} catch (IOException e1) {
RuntimeExceptionHandler.process(e1);
} catch (ParserConfigurationException e1) {
RuntimeExceptionHandler.process(e1);
}
}
}
});
importButton.addMouseListener(new MouseAdapter() {
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.events.MouseAdapter#mouseUp(org.eclipse.swt.events.MouseEvent)
*/
@Override
public void mouseUp(MouseEvent e) {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN);
//$NON-NLS-1$
dialog.setFilterExtensions(new String[] { "*.xml" });
String filePath = dialog.open();
if (filePath != null) {
File file = new File(filePath);
ExpressionFileOperation operation = new ExpressionFileOperation();
try {
List list = operation.importExpressionFromFile(file, getShell());
if (list != null && list.size() != 0) {
expressionComposite.setExpression((String) list.get(0), false);
list.remove(0);
if (list.size() > 0) {
testComposite.addVariables(list);
}
}
} catch (IOException e1) {
RuntimeExceptionHandler.process(e1);
} catch (ParserConfigurationException e1) {
RuntimeExceptionHandler.process(e1);
} catch (SAXException e1) {
RuntimeExceptionHandler.process(e1);
}
}
}
});
}
use of javax.xml.parsers.ParserConfigurationException in project tdi-studio-se by Talend.
the class ExportProjectSettings method saveProjectSettings.
public void saveProjectSettings() {
if (path == null) {
return;
}
File xmlFile = new File(path);
org.talend.core.model.properties.Project project = pro.getEmfProject();
try {
final DocumentBuilderFactory fabrique = DocumentBuilderFactory.newInstance();
DocumentBuilder analyseur = fabrique.newDocumentBuilder();
analyseur.setErrorHandler(new ErrorHandler() {
@Override
public void error(final SAXParseException exception) throws SAXException {
throw exception;
}
@Override
public void fatalError(final SAXParseException exception) throws SAXException {
throw exception;
}
@Override
public void warning(final SAXParseException exception) throws SAXException {
throw exception;
}
});
Document document = analyseur.newDocument();
//$NON-NLS-1$
Element root = document.createElement("exportParameters");
createVersionAttr(document, root);
document.appendChild(root);
// status
List technicals = project.getTechnicalStatus();
//$NON-NLS-1$
createStatus(technicals, document, root, "technicalStatus");
List documentation = project.getDocumentationStatus();
//$NON-NLS-1$
createStatus(documentation, document, root, "documentationStatus");
// security
//$NON-NLS-1$
Element security = document.createElement("exportParameter");
root.appendChild(security);
//$NON-NLS-1$
Attr typeAttr = document.createAttribute("type");
//$NON-NLS-1$
typeAttr.setNodeValue("security");
security.setAttributeNode(typeAttr);
//$NON-NLS-1$
Attr name = document.createAttribute("name");
//$NON-NLS-1$
name.setNodeValue("hidePassword");
security.setAttributeNode(name);
security.setTextContent(String.valueOf(project.isHidePassword()));
// stats and logs
if (project.getStatAndLogsSettings() != null) {
List statAndLogs = project.getStatAndLogsSettings().getParameters().getElementParameter();
//$NON-NLS-1$
saveParameters(document, root, statAndLogs, "statAndLogs");
}
// implicit context
if (project.getImplicitContextSettings() != null) {
List implicit = project.getImplicitContextSettings().getParameters().getElementParameter();
//$NON-NLS-1$
saveParameters(document, root, implicit, "implicitContext");
}
// palette
List componentSettings = project.getComponentsSettings();
savePalette(document, root, componentSettings);
saveDocumentByEncoding(document, xmlFile);
} catch (ParserConfigurationException e) {
ExceptionHandler.process(e);
} catch (IOException e) {
ExceptionHandler.process(e);
}
}
use of javax.xml.parsers.ParserConfigurationException in project tdi-studio-se by Talend.
the class WsdlTokenManager method getValueFromXML.
private String getValueFromXML(String inputXML, String xPathQuery) throws XPathExpressionException, ParserConfigurationException, SAXException, IOException {
DocumentBuilder builder;
try {
builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document document = builder.parse(new ByteArrayInputStream(inputXML.getBytes()));
XPath xpath = XPathFactory.newInstance().newXPath();
String expression = xPathQuery;
Node cipherValue = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);
return cipherValue == null ? null : cipherValue.getTextContent();
} catch (XPathExpressionException e) {
logger.error(e.getMessage());
throw e;
} catch (ParserConfigurationException e) {
logger.error(e.getMessage());
throw e;
} catch (SAXException e) {
logger.error(e.getMessage());
throw e;
} catch (IOException e) {
logger.error(e.getMessage());
throw e;
}
}
Aggregations