use of org.talend.core.model.general.ConnectionBean in project tdi-studio-se by Talend.
the class LoginProjectPage method restartStudio.
protected void restartStudio() {
LoginHelper.isRestart = true;
ConnectionBean iBean = getConnection();
loginHelper.saveLastConnectionBean(iBean);
// update the restart command line to specify the workspace to launch
// if relaunch, should delete the "disableLoginDialog" argument in eclipse data for bug TDI-19214
String workspace = iBean.getWorkSpace();
if (workspace != null) {
//$NON-NLS-1$//$NON-NLS-2$
workspace = workspace.replaceAll("\\\\", "\\\\\\\\");
}
//$NON-NLS-1$
EclipseCommandLine.updateOrCreateExitDataPropertyWithCommand("-data", workspace, false);
// store the workspace in the eclipse history so that it is rememebered on next studio launch
//$NON-NLS-1$
ChooseWorkspaceData workspaceData = new ChooseWorkspaceData("");
workspaceData.workspaceSelected(iBean.getWorkSpace());
workspaceData.writePersistedData();
finishPressed();
}
use of org.talend.core.model.general.ConnectionBean in project tdi-studio-se by Talend.
the class LoginProjectPage method getConnection.
public ConnectionBean getConnection() {
IStructuredSelection sel = (IStructuredSelection) connectionsViewer.getSelection();
ConnectionBean firstElement = (ConnectionBean) sel.getFirstElement();
// }
return firstElement;
}
use of org.talend.core.model.general.ConnectionBean in project tdi-studio-se by Talend.
the class RepositoryService method isloginDialogDisabled.
private boolean isloginDialogDisabled() {
//$NON-NLS-1$
boolean reload = Boolean.parseBoolean(System.getProperty("talend.project.reload"));
PreferenceManipulator preferenceManipulator = new PreferenceManipulator();
ConnectionBean lastBean = null;
if (reload) {
final ConnectionUserPerReader instance = ConnectionUserPerReader.getInstance();
instance.forceReadConnections();
final String lastConncetion = ConnectionUserPerReader.getInstance().readLastConncetion();
for (ConnectionBean bean : instance.readConnections()) {
if (bean.getName().equals(lastConncetion)) {
lastBean = bean;
break;
}
}
}
if (ArrayUtils.contains(Platform.getApplicationArgs(), EclipseCommandLine.TALEND_DISABLE_LOGINDIALOG_COMMAND)) {
//$NON-NLS-1$
boolean deleteProjectIfExist = ArrayUtils.contains(Platform.getApplicationArgs(), "--deleteProjectIfExist");
IBrandingService brandingService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
brandingService.getBrandingConfiguration().setUseProductRegistration(false);
ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
//$NON-NLS-1$ //$NON-NLS-2$
String projectName = getAppArgValue("-project", "AUTO_LOGIN_PROJECT");
//$NON-NLS-1$
String language = getAppArgValue("-language", ECodeLanguage.JAVA.getName());
//$NON-NLS-1$ //$NON-NLS-2$
String login = getAppArgValue("-login", "auto@login.com");
//$NON-NLS-1$ //$NON-NLS-2$
String password = getAppArgValue("-loginPass", "");
//$NON-NLS-1$
String tacURL = getAppArgValue("-tacURL", null);
// if tacURL is null, the branch will be no useful.
//$NON-NLS-1$
String branch = getAppArgValue("-branch", null);
// if tacURL is not null, will be remote
final boolean isRemote = tacURL != null;
if (reload && lastBean != null) {
final String lastProject = preferenceManipulator.getLastProject();
if (lastProject != null) {
projectName = lastProject;
}
final String lastUser = lastBean.getUser();
if (lastUser != null) {
login = lastUser;
}
final String lastPass = lastBean.getPassword();
if (lastPass != null) {
password = lastPass;
}
}
User userInfo = PropertiesFactoryImpl.eINSTANCE.createUser();
userInfo.setLogin(login);
try {
userInfo.setPassword(PasswordHelper.encryptPasswd(password));
} catch (NoSuchAlgorithmException e) {
ExceptionHandler.process(e);
}
LoginHelper.isAutoLogonFailed = false;
try {
ConnectionBean bean = null;
if (reload && lastBean != null) {
// reload
bean = lastBean;
} else {
if (tacURL != null && isRemote) {
// remote
bean = ConnectionBean.getDefaultRemoteConnectionBean();
bean.setUser(login);
bean.setPassword(password);
bean.getDynamicFields().put(RepositoryConstants.REPOSITORY_URL, tacURL);
} else {
bean = ConnectionBean.getDefaultConnectionBean();
}
}
Context ctx = CorePlugin.getContext();
RepositoryContext repositoryContext = new RepositoryContext();
ctx.putProperty(Context.REPOSITORY_CONTEXT_KEY, repositoryContext);
repositoryContext.setUser(userInfo);
repositoryContext.setClearPassword(password);
repositoryContext.setFields(bean.getDynamicFields());
repositoryFactory.setRepositoryFactoryFromProvider(RepositoryFactoryProvider.getRepositoriyById(bean.getRepositoryId()));
Project project = null;
for (Project p : repositoryFactory.readProject()) {
if (p.getLabel().equals(projectName) || p.getTechnicalLabel().equals(projectName)) {
project = p;
break;
}
}
if (!reload) {
if (deleteProjectIfExist && project != null) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProject eclipseProject = workspace.getRoot().getProject(project.getTechnicalLabel());
if (eclipseProject.exists()) {
eclipseProject.delete(true, new NullProgressMonitor());
}
}
if (!isRemote && (project == null || deleteProjectIfExist)) {
Project projectInfor = //$NON-NLS-1$
ProjectHelper.createProject(//$NON-NLS-1$
projectName, //$NON-NLS-1$
"", language, userInfo);
project = repositoryFactory.createProject(projectInfor);
}
} else {
if (project != null && !project.getEmfProject().isLocal() && repositoryFactory.isLocalConnectionProvider()) {
List<IRepositoryFactory> rfList = RepositoryFactoryProvider.getAvailableRepositories();
IRepositoryFactory remoteFactory = null;
for (IRepositoryFactory rf : rfList) {
if (!rf.isLocalConnectionProvider()) {
remoteFactory = rf;
break;
}
}
if (remoteFactory != null) {
repositoryFactory.setRepositoryFactoryFromProvider(remoteFactory);
repositoryFactory.getRepositoryContext().setOffline(true);
}
}
}
if (!repositoryFactory.isLocalConnectionProvider()) {
ProjectManager.getInstance().setMainProjectBranch(project, preferenceManipulator.getLastSVNBranch(new JSONObject(project.getEmfProject().getUrl()).getString("location"), project.getTechnicalLabel()));
}
if (project != null && reload && lastBean != null && repositoryFactory.getRepositoryContext().isOffline()) {
if (PluginChecker.isSVNProviderPluginLoaded()) {
ISVNProviderService svnProviderService = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(ISVNProviderService.class);
if (svnProviderService.isSVNProject(project)) {
String projectUrl = svnProviderService.getProjectUrl(project);
String lastBranch = preferenceManipulator.getLastSVNBranch(projectUrl, project.getTechnicalLabel());
ProjectManager.getInstance().setMainProjectBranch(project, lastBranch);
}
}
}
if (project == null) {
//$NON-NLS-1$
throw new LoginException(Messages.getString("RepositoryService.projectNotFound", projectName));
}
repositoryContext.setProject(project);
repositoryFactory.logOnProject(project, new NullProgressMonitor());
} catch (final PersistenceException e) {
if (e instanceof OperationCancelException) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.getString("LoginDialog.logonCanceled"), e.getLocalizedMessage());
}
});
} else {
MessageBoxExceptionHandler.process(e, new Shell());
}
repositoryFactory.logOffProject();
LoginHelper.isAutoLogonFailed = true;
} catch (LoginException e) {
MessageBoxExceptionHandler.process(e, new Shell());
repositoryFactory.logOffProject();
LoginHelper.isAutoLogonFailed = true;
} catch (BusinessException e) {
MessageBoxExceptionHandler.process(e, new Shell());
repositoryFactory.logOffProject();
LoginHelper.isAutoLogonFailed = true;
} catch (CoreException e) {
MessageBoxExceptionHandler.process(e, new Shell());
repositoryFactory.logOffProject();
LoginHelper.isAutoLogonFailed = true;
} catch (JSONException e) {
ExceptionHandler.process(e);
LoginHelper.isAutoLogonFailed = true;
}
if (LoginHelper.isAutoLogonFailed) {
LoginHelper.isRestart = true;
}
return true;
}
return false;
}
use of org.talend.core.model.general.ConnectionBean in project tdi-studio-se by Talend.
the class CreateAutomaticConnectionApplication method start.
public Object start(IApplicationContext context) throws Exception {
// String[] commandlineArgs = Platform.getCommandLineArgs();
try {
String[] args = Platform.getApplicationArgs();
ConnectionBean newconnection = splitParameters(args);
List<ConnectionBean> connectionList = ConnectionUserPerReader.getInstance().readConnections();
connectionList.add(newconnection);
ConnectionUserPerReader.getInstance().saveConnections(connectionList);
return IApplication.EXIT_OK;
} catch (ParameterIncorrectSetException e) {
//$NON-NLS-N$
MessageDialog.openError(new Shell(), "parameter errors!", e.getMessage());
throw e;
} finally {
// releaseWorkspaceLock();
}
}
use of org.talend.core.model.general.ConnectionBean in project tdi-studio-se by Talend.
the class CreateSandboxProjectDialog method okPressed.
@Override
protected void okPressed() {
// boolean confirm = MessageDialog.openConfirm(getShell(), Messages.getString("CreateSandboxProjectDialog.ConfirmTitle"), //$NON-NLS-1$
// Messages.getString("CreateSandboxProjectDialog.ConfirmMessages")); //$NON-NLS-1$
// if (!confirm) {
// super.okPressed();
// return;
// }
//
final String url = urlText.getText();
final String projectName = projectLabelText.getText();
final String projectLanguage = languageCombo.getText();
final String projectAuthor = userLoginText.getText();
final String projectAuthorPass = userPassText.getText();
final String projectAuthorFirstname = userFirstNameText.getText();
final String projectAuthorLastname = userLastNameText.getText();
// final boolean needCreateNewConn = !existedBeforeConn() || !url.trim().equals(getExistedBeforeConnURL());
bean = new ConnectionBean();
bean.setRepositoryId(RepositoryConstants.REPOSITORY_REMOTE_ID);
bean.setUser(projectAuthor);
bean.setPassword(projectAuthorPass);
bean.setName(generateConnectionName(projectAuthor));
bean.setDescription(bean.getName());
bean.setWorkSpace(new Path(Platform.getInstanceLocation().getURL().getPath()).toFile().getPath());
bean.getDynamicFields().put(RepositoryConstants.REPOSITORY_URL, url);
bean.setComplete(true);
// set context for url and in order to create project later.
RepositoryContext repositoryContext = new RepositoryContext();
// if (existedBeforeConn()) {
// Context ctx = CorePlugin.getContext();
// RepositoryContext oldContext = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
// repositoryContext.setUser(oldContext.getUser());
// repositoryContext.setClearPassword(oldContext.getClearPassword());
// } else {
User user = ProjectHelper.createUser(projectAuthor, projectAuthorPass, projectAuthorFirstname, projectAuthorLastname, false);
repositoryContext.setUser(user);
repositoryContext.setClearPassword(projectAuthorPass);
// }
repositoryContext.setFields(bean.getDynamicFields());
Context ctx = CorePlugin.getContext();
ctx.putProperty(Context.REPOSITORY_CONTEXT_KEY, repositoryContext);
// set provider
// if (!existedBeforeConn()) { // no connection
ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
repositoryFactory.setRepositoryFactoryFromProvider(RepositoryFactoryProvider.getRepositoriyById(bean.getRepositoryId()));
// }
//
IRunnableWithProgress runnable = new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
Display disp = Display.getCurrent();
if (disp == null) {
disp = Display.getDefault();
}
disp.syncExec(new Runnable() {
@Override
public void run() {
//$NON-NLS-1$
monitor.beginTask("Creating...", IProgressMonitor.UNKNOWN);
Project projectInfor = ProjectHelper.createProject(projectName, projectName, projectLanguage, projectAuthor, projectAuthorPass, projectAuthorFirstname, projectAuthorLastname, false);
projectInfor.setSandboxProject(true);
boolean ok = false;
try {
User authUser = originRepCtx.getUser();
String authPassword = originRepCtx.getClearPassword();
Project createProject = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().createProject(authUser, authPassword, projectInfor);
ok = (createProject != null);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
getShell(), //$NON-NLS-1$
Messages.getString("CreateSandboxProjectDialog.Failure"), //$NON-NLS-1$
Messages.getString("CreateSandboxProjectDialog.failureMessage") + "\n\n" + //$NON-NLS-1$
e.getMessage());
}
if (ok) {
// if not created, will don't close the dialog
//$NON-NLS-1$
String messages = Messages.getString("CreateSandboxProjectDialog.successMessage");
// if (needCreateNewConn) {
messages += //$NON-NLS-1$
"\n\n" + //$NON-NLS-1$
Messages.getString("CreateSandboxProjectDialog.creatingConnectionMessages", bean.getName());
// }
MessageDialog.openInformation(getShell(), Messages.getString("CreateSandboxProjectDialog.successTitile"), //$NON-NLS-1$
messages);
// if (needCreateNewConn) {
// save connection
ConnectionUserPerReader instance = ConnectionUserPerReader.getInstance();
List<ConnectionBean> connections = instance.forceReadConnections();
connections.add(bean);
instance.saveConnections(connections);
// }
CreateSandboxProjectDialog.super.okPressed();
}
monitor.done();
}
});
}
};
try {
// final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog(getShell());
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(getShell());
dialog.run(true, false, runnable);
} catch (InvocationTargetException e) {
ExceptionHandler.process(e);
} catch (InterruptedException e) {
ExceptionHandler.process(e);
}
}
Aggregations