use of org.eclipse.core.resources.IFolder in project tdi-studio-se by Talend.
the class TalendProcessJavaProjectTest method testGetSrcFolder.
/**
* Test method for {@link org.talend.designer.runprocess.java.TalendProcessJavaProject#getSrcFolder()}.
*/
@Test
public void testGetSrcFolder() {
IFolder srcFolder = talendJavaProject.getSrcFolder();
Assert.assertNotNull(srcFolder);
Assert.assertTrue(srcFolder.exists());
IPath projectRelativePath = srcFolder.getProjectRelativePath();
Assert.assertEquals(MavenSystemFolders.JAVA.getPath(), projectRelativePath.toString());
}
use of org.eclipse.core.resources.IFolder in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method addRoutinesSourceCodes.
protected void addRoutinesSourceCodes(ExportFileResource[] process, ExportFileResource resource, ITalendProcessJavaProject talendProcessJavaProject, boolean useBeans) throws Exception {
List<IRepositoryViewObject> collectRoutines = new ArrayList<IRepositoryViewObject>();
String include;
if (useBeans) {
include = USER_BEANS_PATH;
} else {
include = USER_ROUTINES_PATH;
}
collectRoutines.addAll(collectRoutines(process, include));
collectRoutines.addAll(collectRoutines(process, USER_PIGUDF_PATH));
Set<String> dependedRoutines = new HashSet<String>();
for (IRepositoryViewObject obj : collectRoutines) {
dependedRoutines.add(//$NON-NLS-1$
obj.getLabel() + "." + ECodeLanguage.JAVA.getExtension());
}
IFolder srcFolder = talendProcessJavaProject.getSrcFolder();
IFolder folder = null;
if (useBeans) {
folder = srcFolder.getFolder(USER_BEANS_PATH);
} else {
folder = srcFolder.getFolder(JavaUtils.JAVA_ROUTINES_DIRECTORY);
}
List<URL> userRoutinesFileUrls = new ArrayList<URL>();
if (folder.exists()) {
for (IResource fileResource : folder.members()) {
if (fileResource instanceof IFile && ((IFile) fileResource).getFileExtension().equals(ECodeLanguage.JAVA.getExtension()) && dependedRoutines.contains(((IFile) fileResource).getName())) {
userRoutinesFileUrls.add(fileResource.getLocationURI().toURL());
}
}
if (useBeans) {
resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + USER_BEANS_PATH, userRoutinesFileUrls);
} else {
resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + JavaUtils.JAVA_ROUTINES_DIRECTORY, userRoutinesFileUrls);
}
}
}
use of org.eclipse.core.resources.IFolder in project tesb-studio-se by Talend.
the class KarafJavaScriptForESBWithMavenManager method addMavenBuildScripts.
@Override
protected void addMavenBuildScripts(ExportFileResource[] processes, List<URL> scriptsUrls, Map<String, String> mavenPropertiesMap) {
if (!PluginChecker.isPluginLoaded(PluginChecker.EXPORT_ROUTE_PLUGIN_ID)) {
return;
}
Item item = processes[0].getItem();
File templatePomFile = null, templateBundleFile = null, templateFeatureFile = null, templateParentFile = null;
if (item != null) {
IPath itemLocationPath = ItemResourceUtil.getItemLocationPath(item.getProperty());
IFolder objectTypeFolder = ItemResourceUtil.getObjectTypeFolder(item.getProperty());
if (itemLocationPath != null && objectTypeFolder != null) {
IPath itemRelativePath = itemLocationPath.removeLastSegments(1).makeRelativeTo(objectTypeFolder.getLocation());
templatePomFile = PomUtil.getTemplateFile(objectTypeFolder, itemRelativePath, TalendMavenConstants.POM_FILE_NAME);
if (FilesUtils.allInSameFolder(templatePomFile, IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_BUNDLE_FILE_NAME, IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_FEATURE_FILE_NAME, IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_PARENT_FILE_NAME)) {
templateBundleFile = new File(templatePomFile.getParentFile(), IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_BUNDLE_FILE_NAME);
templateFeatureFile = new File(templatePomFile.getParentFile(), IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_FEATURE_FILE_NAME);
templateParentFile = new File(templatePomFile.getParentFile(), IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_PARENT_FILE_NAME);
} else {
// don't use template file from repository.
// other files is not init, so no need set null at all.
templatePomFile = null;
}
}
}
File mavenBuildFile = new File(getTmpFolder() + PATH_SEPARATOR + IProjectSettingTemplateConstants.POM_FILE_NAME);
File mavenBuildBundleFile = new File(getTmpFolder() + PATH_SEPARATOR + IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_BUNDLE_FILE_NAME);
File mavenBuildFeatureFile = new File(getTmpFolder() + PATH_SEPARATOR + IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_FEATURE_FILE_NAME);
File mavenBuildParentFile = new File(getTmpFolder() + PATH_SEPARATOR + IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_PARENT_FILE_NAME);
try {
final Map<String, Object> templateParameters = PomUtil.getTemplateParameters(item.getProperty());
String mavenScript = MavenTemplateManager.getTemplateContent(templatePomFile, IProjectSettingPreferenceConstants.TEMPLATE_ROUTES_KARAF_POM, PluginChecker.EXPORT_ROUTE_PLUGIN_ID, IProjectSettingTemplateConstants.PATH_ROUTE + '/' + TalendMavenConstants.POM_FILE_NAME, templateParameters);
if (mavenScript != null) {
createMavenBuildFileFromTemplate(mavenBuildFile, mavenScript);
updateMavenBuildFileContent(mavenBuildFile, mavenPropertiesMap, false, true);
scriptsUrls.add(mavenBuildFile.toURI().toURL());
}
mavenScript = MavenTemplateManager.getTemplateContent(templateBundleFile, IProjectSettingPreferenceConstants.TEMPLATE_ROUTES_KARAF_BUNDLE, PluginChecker.EXPORT_ROUTE_PLUGIN_ID, IProjectSettingTemplateConstants.PATH_ROUTE + '/' + IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_BUNDLE_FILE_NAME, templateParameters);
if (mavenScript != null) {
createMavenBuildFileFromTemplate(mavenBuildBundleFile, mavenScript);
updateMavenBuildFileContent(mavenBuildBundleFile, mavenPropertiesMap, true, false);
scriptsUrls.add(mavenBuildBundleFile.toURI().toURL());
}
mavenScript = MavenTemplateManager.getTemplateContent(templateFeatureFile, IProjectSettingPreferenceConstants.TEMPLATE_ROUTES_KARAF_FEATURE, PluginChecker.EXPORT_ROUTE_PLUGIN_ID, IProjectSettingTemplateConstants.PATH_ROUTE + '/' + IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_FEATURE_FILE_NAME, templateParameters);
if (mavenScript != null) {
createMavenBuildFileFromTemplate(mavenBuildFeatureFile, mavenScript);
updateMavenBuildFileContent(mavenBuildFeatureFile, mavenPropertiesMap);
scriptsUrls.add(mavenBuildFeatureFile.toURI().toURL());
}
mavenScript = MavenTemplateManager.getTemplateContent(templateParentFile, IProjectSettingPreferenceConstants.TEMPLATE_ROUTES_KARAF_PARENT, PluginChecker.EXPORT_ROUTE_PLUGIN_ID, IProjectSettingTemplateConstants.PATH_ROUTE + '/' + IProjectSettingTemplateConstants.MAVEN_KARAF_BUILD_PARENT_FILE_NAME, templateParameters);
if (mavenScript != null) {
createMavenBuildFileFromTemplate(mavenBuildParentFile, mavenScript);
updateMavenBuildFileContent(mavenBuildParentFile, mavenPropertiesMap);
scriptsUrls.add(mavenBuildParentFile.toURI().toURL());
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
}
use of org.eclipse.core.resources.IFolder in project tesb-studio-se by Talend.
the class RouteResourceUtil method synchronizeRouteResource.
public static Collection<IPath> synchronizeRouteResource(final ProcessItem item) {
final boolean routelet;
if (item.eClass() == CamelPropertiesPackage.Literals.CAMEL_PROCESS_ITEM) {
routelet = false;
} else if (item.eClass() == CamelPropertiesPackage.Literals.ROUTELET_PROCESS_ITEM) {
routelet = true;
} else {
return null;
}
if (!GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
return null;
}
final IRunProcessService processService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
final ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
if (talendProcessJavaProject == null) {
return null;
}
final IFolder routeResourceFolder = talendProcessJavaProject.getResourcesFolder();
final Collection<IPath> result = new ArrayList<IPath>();
// add spring file
if (!routelet) {
final IFolder metaInf = routeResourceFolder.getFolder("META-INF/spring/");
try {
prepareFolder(metaInf);
final IFile spring = metaInf.getFile(item.getProperty().getLabel().toLowerCase() + ".xml");
final InputStream inputStream = new ByteArrayInputStream(((CamelProcessItem) item).getSpringContent().getBytes());
if (spring.exists()) {
spring.setContents(inputStream, 0, null);
} else {
spring.create(inputStream, true, null);
}
result.add(spring.getLocation());
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
for (ResourceDependencyModel model : getResourceDependencies(item)) {
IFile file = copyResources(routeResourceFolder, model);
if (file != null) {
result.add(file.getLocation());
}
}
return result;
}
use of org.eclipse.core.resources.IFolder in project sling by apache.
the class JcrNode method prune.
private void prune(IContainer folder) throws CoreException {
if (folder == null || !(folder instanceof IFolder)) {
return;
}
IFolder f = (IFolder) folder;
IResource[] members = f.members();
if (members != null && members.length != 0) {
return;
}
f.delete(true, new NullProgressMonitor());
prune(folder.getParent());
}
Aggregations