use of org.talend.core.model.general.ILibrariesService in project tdi-studio-se by Talend.
the class ImportItemUtil method deployJarToDesForArchive.
private void deployJarToDesForArchive(final ResourcesManager manager, Set<String> extRoutines) {
if (extRoutines.isEmpty()) {
return;
}
//$NON-NLS-1$
IPath tmpDir = new Path(System.getProperty("user.dir") + File.separatorChar + "tmpJar");
Set<URL> jarsToDeploy = new HashSet<URL>();
File dirFile = tmpDir.toFile();
for (IPath path : manager.getPaths()) {
String fileName = path.lastSegment();
if (extRoutines.contains(fileName)) {
try {
InputStream is = manager.getStream(path);
if (!dirFile.exists()) {
dirFile.mkdirs();
}
File temFile = tmpDir.append(fileName).toFile();
if (temFile.exists()) {
temFile.delete();
}
byte[] b = new byte[1024];
int length = 0;
BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(temFile, true));
while ((length = is.read(b)) != -1) {
fos.write(b, 0, length);
}
fos.close();
jarsToDeploy.add(temFile.toURI().toURL());
} catch (MalformedURLException e) {
ExceptionHandler.process(e);
} catch (IOException e) {
ExceptionHandler.process(e);
}
}
}
if (jarsToDeploy.size() > 0) {
ILibrariesService libService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
try {
libService.deployLibrarys(jarsToDeploy.toArray(new URL[0]));
} catch (IOException e) {
ExceptionHandler.process(e);
}
}
dirFile.delete();
}
use of org.talend.core.model.general.ILibrariesService in project tesb-studio-se by Talend.
the class SyncNexusButtonController method createCommand.
public Command createCommand(Button button) {
IElementParameter parameter = (IElementParameter) button.getData();
if (parameter != null) {
callBeforeActive(parameter);
// so as to invoke listeners to perform some actions.
IElementParameter elementParameterFromField = elem.getElementParameter("DRIVER_JAR");
IElementParameter needUpdateList = elem.getElementParameter("NEED_UPDATE_LIST");
List needUpdateJars = (List) needUpdateList.getValue();
if (needUpdateJars != null && needUpdateJars.size() == 0) {
MessageDialog.openInformation(composite.getShell(), "Synchronizing libraries", "Everything is up-to-date");
} else {
for (int i = 0; i < needUpdateJars.size(); i++) {
Map<String, Object> jar = (Map) needUpdateJars.get(i);
String jn = TalendQuoteUtils.removeQuotes(jar.get("JAR_NAME").toString());
String jnv = TalendQuoteUtils.removeQuotes(jar.get("JAR_NEXUS_VERSION").toString());
String a = jn.replaceFirst("[.][^.]+$", "");
if (Boolean.valueOf(jar.get("JAR_SYNC").toString())) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
ILibrariesService librariesService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
InputStream is = service.getContentInputStream(nexusServerBean, "", getGroupId(), a, jnv, null);
File file = generateTempFile(is, jn);
try {
librariesService.deployLibrary(file.toURI().toURL(), "mvn:org.talend.libraries/" + a + "/" + jnv + "/jar");
jar.put("JAR_STATUS", "✔");
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
refresh(needUpdateList, true);
return null;
}
return null;
}
use of org.talend.core.model.general.ILibrariesService in project tdi-studio-se by Talend.
the class JSONFileStep1Form method setVisible.
/*
* (non-Javadoc)
*
* @see org.eclipse.swt.widgets.Control#setVisible(boolean)
*/
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
if (isReadOnly() != readOnly) {
adaptFormToReadOnly();
}
if (super.isVisible()) {
String JSONFilePath = getConnection().getJSONFilePath();
// Fields to the Group Delimited File Settings
if (getConnection().getEncoding() != null && !getConnection().getEncoding().equals("")) {
//$NON-NLS-1$
encodingCombo.setText(getConnection().getEncoding());
isModifing = false;
fileFieldJSON.setText(JSONFilePath);
} else {
encodingCombo.select(0);
}
if (isContextMode()) {
ContextType contextType = ConnectionContextHelper.getContextTypeForContextMode(connectionItem.getConnection(), connectionItem.getConnection().getContextName());
JSONFilePath = TalendQuoteUtils.removeQuotes(ConnectionContextHelper.getOriginalValue(contextType, JSONFilePath));
}
if (!creation) {
updateTreeNodes(JSONFilePath);
JSONWizard wizard = ((JSONWizard) getPage().getWizard());
if (wizard.getTreeRootNode() == null) {
wizard.setTreeRootNode(treeNode);
}
}
if (LanguageManager.getCurrentLanguage() == ECodeLanguage.PERL && GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
ILibrariesService moduleService = (ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
try {
ELibraryInstallStatus status = moduleService.getLibraryStatus("JSON::LibJSON");
if (status != ELibraryInstallStatus.INSTALLED) {
new ErrorDialogWidthDetailArea(getShell(), PID, "The Perl Module" + " JSON::LibJSON " + "is not installed", "For more information, check out Talend's Wiki website at http\\://talendforge.org/wiki/doku.php.");
log.error("The Perl Module" + " JSON::LibJSONL " + "is not installed");
}
} catch (BusinessException e) {
new ErrorDialogWidthDetailArea(getShell(), PID, "The Perl Module" + " JSON::LibJSON " + "is not installed", "For more information, check out Talend's Wiki website at http\\://talendforge.org/wiki/doku.php.");
log.error("The Perl Module" + " JSON::LibJSONL " + "is not installed");
}
}
adaptFormToEditable();
}
}
use of org.talend.core.model.general.ILibrariesService in project tbd-studio-se by Talend.
the class AbstractDynamicDistributionTemplate method registPluginExtensions.
@Override
public boolean registPluginExtensions() {
if (registedPluginAdapter == null) {
synchronized (registedPluginAdapterLock) {
if (registedPluginAdapter == null) {
DynamicPluginAdapter plugAdapter = getPluginAdapter();
IDynamicPlugin plugin = plugAdapter.getPlugin();
IDynamicPluginConfiguration pConfiguration = plugin.getPluginConfiguration();
try {
plugin.setPluginConfiguration(null);
DynamicServiceUtil.addContribution(plugAdapter.getBundle(), plugin);
registedPluginAdapter = plugAdapter;
ILibrariesService libService = ILibrariesService.get();
if (libService != null) {
libService.resetModulesNeeded();
}
HadoopDistributionsHelper.updatePluginExtensionCacheVersion();
return true;
} catch (Exception e) {
ExceptionHandler.process(e);
} finally {
plugin.setPluginConfiguration(pConfiguration);
}
}
}
}
return false;
}
use of org.talend.core.model.general.ILibrariesService in project tdi-studio-se by Talend.
the class AbstractTalendEditor method doSave.
@Override
public void doSave(IProgressMonitor monitor) {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
//$NON-NLS-1$
monitor.beginTask("begin save job...", 100);
monitor.worked(10);
savePreviewPictures();
// generate the MR infor parameter.
try {
boolean isStormServiceRegistered = GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class);
boolean isMRServiceRegistered = GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class);
if (isStormServiceRegistered || isMRServiceRegistered) {
IProcess2 process = getProcess();
if (process != null) {
IRepositoryViewObject repoObjectView = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getLastVersion(process.getId());
if (repoObjectView != null && repoObjectView.getProperty() != null) {
Item currentItem = repoObjectView.getProperty().getItem();
if (isMRServiceRegistered) {
IMRProcessService mrService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
if (mrService.isMapReduceItem(currentItem)) {
// We make sure that the current item is a Batch item before generating the M/R
// information parameters.
mrService.generateMRInfosParameter(process);
}
}
if (isStormServiceRegistered) {
IStormProcessService stormService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
if (stormService.isStormItem(currentItem)) {
// We make sure that the current item is a Streaming item before generating the Spark
// Streaming information parameters.
stormService.generateSparkStreamingInfosParameter(process);
}
}
}
}
}
} catch (PersistenceException e) {
e.printStackTrace();
}
try {
if (getEditorInput() instanceof JobEditorInput) {
boolean saved = ((JobEditorInput) getEditorInput()).saveProcess(new SubProgressMonitor(monitor, 80), null);
if (!saved) {
monitor.setCanceled(true);
throw new InterruptedException();
}
}
getCommandStack().markSaveLocation();
setDirty(false);
boolean isneedReload = false;
for (int i = 0; i < getProcess().getGraphicalNodes().size(); i++) {
Node node = (Node) getProcess().getGraphicalNodes().get(i);
if (node.isNeedloadLib()) {
isneedReload = true;
node.setNeedLoadLib(false);
}
}
if (isneedReload) {
// / See bug 4821
((ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class)).updateModulesNeededForCurrentJob(getProcess());
}
monitor.worked(10);
} catch (Exception e) {
// e.printStackTrace();
ExceptionHandler.process(e);
monitor.setCanceled(true);
} finally {
monitor.done();
}
}
Aggregations