use of org.eclipse.core.filesystem.IFileSystem in project tesb-studio-se by Talend.
the class Activator method copyConfigs.
private void copyConfigs() throws CoreException, IOException, URISyntaxException {
// find ESB configuration files folder in plug-in
URL esbConfigsFolderUrl = FileLocator.find(getBundle(), new Path("esb"), null);
if (null == esbConfigsFolderUrl) {
getLog().log(new Status(IStatus.WARNING, getBundle().getSymbolicName(), "cannot find ESB configuration files"));
return;
}
// resolve plug-in ESB config folder URL into file protocol URL
esbConfigsFolderUrl = FileLocator.toFileURL(esbConfigsFolderUrl);
// create ESB configuration folder under Studio instalation
IFileSystem fileSystem = EFS.getLocalFileSystem();
IFileStore esbConfigsTargetFolder = fileSystem.getStore(EsbConfigUtils.getEclipseEsbFolder().toURI());
esbConfigsTargetFolder = esbConfigsTargetFolder.mkdir(EFS.SHALLOW, null);
// retrieve all ESB configuration files packed inside plug-in
File fileEsbConfigFolder = new File(esbConfigsFolderUrl.getPath());
IFileStore esbConfigsFolderStore = fileSystem.getStore(fileEsbConfigFolder.toURI());
IFileStore[] esbConfigsFolderStoreChildren = esbConfigsFolderStore.childStores(EFS.NONE, null);
if (0 == esbConfigsFolderStoreChildren.length) {
getLog().log(new Status(IStatus.WARNING, getBundle().getSymbolicName(), "cannot find any ESB configuration files"));
return;
}
// try to copy ESB configuration files (without overwriting)
for (IFileStore esbConfigFileStore : esbConfigsFolderStoreChildren) {
if (!esbConfigFileStore.fetchInfo().isDirectory()) {
String esbConfigFileName = esbConfigFileStore.fetchInfo().getName();
try {
esbConfigFileStore.copy(esbConfigsTargetFolder.getChild(esbConfigFileName), EFS.NONE, null);
} catch (CoreException e) {
// ignore to do not overwrite possible user changes in configuration files
return;
}
} else {
String esbConfigFileName = esbConfigFileStore.fetchInfo().getName();
if ("microservice".equals(esbConfigFileName) && PluginChecker.isTIS()) {
try {
esbConfigFileStore.copy(esbConfigsTargetFolder.getChild(esbConfigFileName), EFS.NONE, null);
} catch (CoreException e) {
// ignore to do not overwrite possible user changes in configuration files
return;
}
}
}
}
}
Aggregations