use of org.eclipse.core.runtime.Status in project tdi-studio-se by Talend.
the class ShadowFilePreview method preview.
/*
* (non-Javadoc)
*
* @see org.talend.repository.preview.IPreview#preview(org.talend.repository.preview.IProcessDescription,
* java.lang.String, boolean)
*/
public CsvArray preview(IProcessDescription description, String type, boolean outputErrorAsException) throws CoreException {
CsvArray res = null;
EShadowProcessType typeShadow = EShadowProcessType.valueOf(type);
shadowProcess = new ShadowProcess<IProcessDescription>(description, typeShadow);
try {
res = shadowProcess.runWithErrorOutputAsException(outputErrorAsException);
} catch (ProcessorException e) {
Status status = new Status(Status.ERROR, RunProcessPlugin.PLUGIN_ID, Status.OK, e.getMessage(), e);
RunProcessPlugin.getDefault().getLog().log(status);
throw new CoreException(status);
}
return res;
}
use of org.eclipse.core.runtime.Status in project tdi-studio-se by Talend.
the class JavaProcessor method getLineNumbers.
/**
* Find line numbers of the beginning of the code of process nodes.
*
* @param file Code file where we are searching node's code.
* @param nodes List of nodes searched.
* @return Line numbers where code of nodes appears.
* @throws CoreException Search failed.
*/
private static int[] getLineNumbers(IFile file, String[] nodes) throws CoreException {
List<Integer> lineNumbers = new ArrayList<Integer>();
// List of code's lines searched in the file
List<String> searchedLines = new ArrayList<String>();
for (String node : nodes) {
searchedLines.add(node);
}
LineNumberReader lineReader = new LineNumberReader(new InputStreamReader(file.getContents()));
try {
String line = lineReader.readLine();
while (!searchedLines.isEmpty() && line != null) {
boolean nodeFound = false;
for (Iterator<String> i = searchedLines.iterator(); !nodeFound && i.hasNext(); ) {
String nodeMain = i.next();
if (line.indexOf(nodeMain) != -1) {
nodeFound = true;
i.remove();
// Search the first valid code line
boolean lineCodeFound = false;
line = lineReader.readLine();
while (line != null && !lineCodeFound) {
if (isCodeLine(line)) {
lineCodeFound = true;
lineNumbers.add(new Integer(lineReader.getLineNumber() + 1));
}
line = lineReader.readLine();
}
}
}
line = lineReader.readLine();
}
} catch (IOException ioe) {
//$NON-NLS-1$ //$NON-NLS-2$
IStatus status = new Status(IStatus.ERROR, "", IStatus.OK, "Source code read failure.", ioe);
throw new CoreException(status);
}
int[] res = new int[lineNumbers.size()];
int pos = 0;
for (Integer i : lineNumbers) {
res[pos++] = i.intValue();
}
return res;
}
use of org.eclipse.core.runtime.Status in project tdi-studio-se by Talend.
the class JavaProcessor method copyEsbConfigFile.
private static void copyEsbConfigFile(File esbConfigsSourceFolder, IFolder esbConfigsTargetFolder, String configFile) {
File esbConfig = new File(esbConfigsSourceFolder, configFile);
if (esbConfig.exists()) {
try {
IFile target = esbConfigsTargetFolder.getFile(configFile);
InputStream is = null;
try {
is = new FileInputStream(esbConfig);
if (!target.exists()) {
target.create(is, true, null);
} else {
target.setContents(is, true, false, null);
}
} finally {
if (null != is) {
is.close();
}
}
// esbConfig.copy(esbConfigsTargetFolder.getChild(configFile), EFS.OVERWRITE, null);
} catch (Exception e) {
RunProcessPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, RunProcessPlugin.getDefault().getBundle().getSymbolicName(), //$NON-NLS-1$
"cannot add configuration file on classpath - " + configFile, e));
}
} else {
RunProcessPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, RunProcessPlugin.getDefault().getBundle().getSymbolicName(), //$NON-NLS-1$
"cannot find configuration file - " + esbConfig.toURI()));
}
}
use of org.eclipse.core.runtime.Status in project tdi-studio-se by Talend.
the class JSONShadowFilePreview method preview.
/*
* (non-Javadoc)
*
* @see org.talend.repository.preview.IPreview#preview(org.talend.repository.preview.IProcessDescription,
* java.lang.String, boolean)
*/
public CsvArray preview(IProcessDescription description, String type, boolean outputErrorAsException) throws CoreException {
CsvArray res = null;
EJSONShadowProcessType typeShadow = EJSONShadowProcessType.valueOf(type);
shadowProcess = new JSONShadowProcess<IProcessDescription>(description, typeShadow);
try {
res = shadowProcess.runWithErrorOutputAsException(outputErrorAsException);
} catch (ProcessorException e) {
Status status = new Status(Status.ERROR, RunProcessPlugin.PLUGIN_ID, Status.OK, e.getMessage(), e);
RunProcessPlugin.getDefault().getLog().log(status);
throw new CoreException(status);
}
return res;
}
use of org.eclipse.core.runtime.Status in project tdi-studio-se by Talend.
the class JSONShadowFilePreview method preview.
/*
* (non-Javadoc)
*
* @see org.talend.repository.preview.filedelimited.IFileDelimitedPreview#
* preview(org.talend.repository.preview.filedelimited.ProcessDescription)
*/
public CsvArray preview(IProcessDescription description, String type) throws CoreException {
CsvArray res = null;
EJSONShadowProcessType typeShadow = EJSONShadowProcessType.valueOf(type);
shadowProcess = new JSONShadowProcess<IProcessDescription>(description, typeShadow);
try {
res = shadowProcess.run();
} catch (ProcessorException e) {
Status status = new Status(Status.ERROR, RunProcessPlugin.PLUGIN_ID, Status.OK, e.getMessage(), e);
RunProcessPlugin.getDefault().getLog().log(status);
throw new CoreException(status);
}
return res;
}
Aggregations