use of org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference in project tbd-studio-se by Talend.
the class DynamicDistributionPreferenceForm method checkRepository.
private boolean checkRepository() {
try {
repositoryText.setBackground(null);
// $NON-NLS-1$
repositoryText.setToolTipText("");
boolean overrideDefaultSetupSelected = overrideDefaultSetupBtn.getSelection();
repositoryText.setEditable(overrideDefaultSetupSelected);
if (!overrideDefaultSetupSelected) {
IDynamicDistributionsGroup selectedSetupDynamicDistriGroup = getSelectedSetupDynamicDistriGroup();
if (selectedSetupDynamicDistriGroup != null) {
IDynamicDistributionPreference dynamicDistributionPreference = selectedSetupDynamicDistriGroup.getDynamicDistributionPreference(ProjectManager.getInstance().getCurrentProject());
String defaultRepository = dynamicDistributionPreference.getDefaultRepository();
repositoryText.setText(defaultRepository);
repositoryText.setToolTipText(defaultRepository);
}
} else {
String repository = repositoryText.getText();
if (StringUtils.isEmpty(repository.trim())) {
String errorMessage = Messages.getString(// $NON-NLS-1$
"DynamicDistributionPreferenceForm.exception.setup.override.repository.empty");
repositoryText.setToolTipText(errorMessage);
repositoryText.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
showMessage(errorMessage, WizardPage.ERROR);
return false;
} else {
repositoryText.setToolTipText(repository);
}
}
} catch (Exception e) {
ExceptionHandler.process(e);
return false;
} finally {
boolean isReadonly = isReadonly();
if (isReadonly) {
overrideDefaultSetupBtn.setEnabled(false);
repositoryText.setEditable(false);
}
}
return true;
}
use of org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference in project tbd-studio-se by Talend.
the class AbstractDynamicDistribution method register.
@Override
public void register(IDynamicPlugin dynamicPlugin, IDynamicMonitor monitor) throws Exception {
DynamicDistributionManager dynamicDistributionManager = DynamicDistributionManager.getInstance();
IDynamicPlugin copiedDynamicPlugin = DynamicFactory.getInstance().createPluginFromJson(dynamicPlugin.toXmlJson().toString());
Project project = ProjectManager.getInstance().getProjectFromProjectTechLabel((String) copiedDynamicPlugin.getPluginConfiguration().getAttribute(DynamicConstants.ATTR_PROJECT_TECHNICAL_NAME));
IDynamicDistributionPreference dynamicDistributionPreference = dynamicDistributionManager.getDynamicDistributionGroup(getDistributionName()).getDynamicDistributionPreference(project);
Bundle bundle = getBundle();
DynamicPluginAdapter pluginAdapter = new DynamicPluginAdapter(copiedDynamicPlugin, dynamicDistributionPreference, bundle);
pluginAdapter.adapt();
IDynamicPluginConfiguration pluginConfiguration = pluginAdapter.getPluginConfiguration();
String id = pluginConfiguration.getId();
try {
IDynamicDistributionTemplate existingTemplate = registedDistribution.get(id);
if (existingTemplate != null) {
unloadDistribution(existingTemplate, true);
DynamicPluginAdapter existingPluginAdapter = existingTemplate.getPluginAdapter();
IDynamicPluginConfiguration existingPluginConfig = existingPluginAdapter.getPluginConfiguration();
String existingProjectName = (String) existingPluginConfig.getAttribute(DynamicConstants.ATTR_PROJECT_TECHNICAL_NAME);
ExceptionHandler.log("Dynamic distribution: " + existingProjectName + "/" + id + " already exists, unloaded the old one and reload the new one");
}
} catch (Exception e) {
ExceptionHandler.process(e);
}
boolean isBuiltin = Boolean.parseBoolean((String) pluginConfiguration.getAttribute(DynamicConstants.ATTR_IS_BUILTIN));
if (isBuiltin) {
// $NON-NLS-1$
pluginConfiguration.setName(Messages.getString("DynamicDistribution.name.builtin", pluginConfiguration.getName()));
} else {
Project currentProject = ProjectManager.getInstance().getCurrentProject();
String curProjLabel = currentProject.getTechnicalLabel();
String projLabel = (String) pluginConfiguration.getAttribute(DynamicConstants.ATTR_PROJECT_TECHNICAL_NAME);
if (StringUtils.equals(curProjLabel, projLabel)) {
// $NON-NLS-1$
projLabel = Messages.getString("DynamicDistribution.name.current");
}
pluginConfiguration.setName(// $NON-NLS-1$
Messages.getString(// $NON-NLS-1$
"DynamicDistribution.name.project", // $NON-NLS-1$
pluginConfiguration.getName(), projLabel));
}
IDynamicDistributionTemplate distributionTemplate = initTemplate(pluginAdapter, monitor);
registedDistribution.put(pluginConfiguration.getId(), distributionTemplate);
distributionTemplate.registOsgiServices();
if (Boolean.getBoolean(PROP_LOAD_DYNAMIC_DISTRIBUTION_MODULE)) {
distributionTemplate.registPluginExtensions();
}
}
use of org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference in project tbd-studio-se by Talend.
the class AbstractDependencyResolver method listVersions.
@Override
public List<String> listVersions(String groupId, String artifactId, String baseVersion, String topVersion, IDynamicMonitor monitor) throws Exception {
IDynamicDistributionPreference preference = configuration.getPreference();
String remoteRepositoryUrl = preference.getRepository();
String username = null;
String password = null;
if (!preference.isAnonymous()) {
username = preference.getUsername();
password = preference.getPassword();
}
String localRepositoryPath = getLocalRepositoryPath();
return DynamicDistributionAetherUtils.versionRange(remoteRepositoryUrl, username, password, localRepositoryPath, groupId, artifactId, null, null, monitor);
}
use of org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference in project tbd-studio-se by Talend.
the class AbstractDependencyResolver method collectDependencies.
@Override
public DependencyNode collectDependencies(DependencyNode baseNode, IDynamicMonitor monitor, boolean multiThread) throws Exception {
String version = baseNode.getVersion();
if (StringUtils.isEmpty(version)) {
String groupId = baseNode.getGroupId();
String artifactId = baseNode.getArtifactId();
version = getDependencyVersionByHadoopVersion(groupId, artifactId, monitor);
if (StringUtils.isEmpty(version)) {
VersionNotFoundException versionNotFound = new VersionNotFoundException();
versionNotFound.setVersion(configuration.getVersion());
versionNotFound.setBaseNode(baseNode);
throw versionNotFound;
}
baseNode.setVersion(version);
}
IDynamicDistributionPreference preference = configuration.getPreference();
String remoteRepositoryUrl = preference.getRepository();
String username = null;
String password = null;
if (!preference.isAnonymous()) {
username = preference.getUsername();
password = preference.getPassword();
}
String localRepositoryPath = getLocalRepositoryPath();
DependencyNode node = DynamicDistributionAetherUtils.collectDepencencies(remoteRepositoryUrl, username, password, localRepositoryPath, baseNode, monitor, multiThread);
return node;
}
use of org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference in project tbd-studio-se by Talend.
the class AbstractDynamicDistributionSetupForm method saveDynamicDistribution.
protected void saveDynamicDistribution(IDynamicPlugin dynamicPlugin, IDynamicDistributionsGroup dynDistrGroup, ActionType actionType, IDynamicMonitor dMonitor) throws Exception {
IDynamicPluginConfiguration pluginConfiguration = dynamicPlugin.getPluginConfiguration();
dMonitor.beginTask(// $NON-NLS-1$
Messages.getString("AbstractDynamicDistributionSetupForm.progress.saving", pluginConfiguration.getName()), IDynamicMonitor.UNKNOWN);
// step 1: clean unused modules
IDynamicDistributionPreference dynamicDistributionPreference = dynDistrGroup.getDynamicDistributionPreference(ProjectManager.getInstance().getCurrentProject());
DynamicPluginAdapter pluginAdapter = new DynamicPluginAdapter(dynamicPlugin, dynamicDistributionPreference, null);
pluginAdapter.cleanUnusedAndRefresh();
// step 2: save
final IDynamicPlugin fDynPlugin = pluginAdapter.getPlugin();
ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(new RepositoryWorkUnit<Boolean>(Messages.getString("AbstractDynamicDistributionSetupForm.repositoryWorkUnit.title", // $NON-NLS-1$
pluginConfiguration.getName())) {
@Override
protected void run() throws LoginException, PersistenceException {
result = false;
try {
DynamicDistributionManager.getInstance().saveUsersDynamicPlugin(fDynPlugin, dMonitor);
} catch (Exception e) {
throw new PersistenceException(e);
}
result = true;
}
});
// step 3: regist
dMonitor.setTaskName(// $NON-NLS-1$
Messages.getString("AbstractDynamicDistributionSetupForm.progress.registing", pluginConfiguration.getName()));
if (ActionType.EditExisting.equals(actionType)) {
dynDistrGroup.unregister(fDynPlugin, dMonitor, false);
}
dynDistrGroup.register(fDynPlugin, dMonitor);
// step 4: reset system cache
// $NON-NLS-1$
dMonitor.setTaskName(Messages.getString("AbstractDynamicDistributionSetupForm.progress.resetCache"));
DynamicDistributionManager.getInstance().resetSystemCache();
}
Aggregations