use of org.talend.repository.items.importexport.manager.ResourcesManager in project tdi-studio-se by Talend.
the class DemoImportTestUtil method getResourceManagers.
public static List<ResourcesManager> getResourceManagers(List<DemoProjectBean> checkedProjectBean) {
List<ResourcesManager> resManagers = new ArrayList<ResourcesManager>();
try {
for (DemoProjectBean pro : checkedProjectBean) {
ResourcesManager resManager = null;
Bundle bundle = Platform.getBundle(pro.getPluginId());
URL demoURL = FileLocator.find(bundle, new Path(pro.getDemoProjectFilePath()), null);
demoURL = FileLocator.toFileURL(demoURL);
String filePath = new Path(demoURL.getFile()).toOSString();
File srcFile = new File(filePath);
FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
resManager = fileUnityManager.doUnify();
if (resManager != null) {
resManagers.add(resManager);
}
}
} catch (ZipException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (TarException e) {
e.printStackTrace();
}
return resManagers;
}
use of org.talend.repository.items.importexport.manager.ResourcesManager in project tdi-studio-se by Talend.
the class TalendImportUtil method importItems.
public static boolean importItems(String zipPath, IProgressMonitor monitor, final boolean overwrite, final boolean openThem, boolean needMigrationTask) throws IOException {
// File srcFile = new File(zipPath);
ZipFile srcZipFile = new ZipFile(zipPath);
final ImportExportHandlersManager importManager = new ImportExportHandlersManager();
final ResourcesManager resourcesManager = ResourcesManagerFactory.getInstance().createResourcesManager(srcZipFile);
// resourcesManager.collectPath2Object(srcFile);
resourcesManager.collectPath2Object(srcZipFile);
final List<ImportItem> items = populateItems(importManager, resourcesManager, monitor, overwrite);
final List<String> itemIds = new ArrayList<String>();
try {
for (ImportItem itemRecord : items) {
Item item = itemRecord.getProperty().getItem();
if (item instanceof ProcessItem) {
// only select jobs
itemIds.add(item.getProperty().getId());
}
IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
if (item.getState().isLocked()) {
factory.unlock(item);
}
ERepositoryStatus status = factory.getStatus(item);
if (status != null && status == ERepositoryStatus.LOCK_BY_USER) {
factory.unlock(item);
}
if (!needMigrationTask) {
itemRecord.setMigrationTasksToApply(null);
}
}
// nodesBuilder.getAllImportItemRecords(), null);
if (items != null && !items.isEmpty()) {
importManager.importItemRecords(monitor, resourcesManager, items, overwrite, nodesBuilder.getAllImportItemRecords(), null);
}
} catch (Exception e) {
CommonExceptionHandler.process(e);
} finally {
// clean
if (resourcesManager != null) {
resourcesManager.closeResource();
}
nodesBuilder.clear();
}
return true;
}
Aggregations