use of org.talend.commons.exception.BusinessException in project tdi-studio-se by Talend.
the class LoginHelper method getProjects.
public Project[] getProjects(ConnectionBean connBean, ErrorManager errorManager) {
if (connBean == null) {
return null;
}
Project[] projects = null;
if (connBean != null) {
String user2 = connBean.getUser();
String repositoryId2 = connBean.getRepositoryId();
String workSpace = connBean.getWorkSpace();
String name = connBean.getName();
if (//$NON-NLS-1$ //$NON-NLS-2$
user2 != null && !"".equals(user2) && repositoryId2 != null && !"".equals(repositoryId2) && workSpace != null && !"".equals(workSpace) && name != null && !"".equals(name)) {
//$NON-NLS-1$ //$NON-NLS-2$
boolean valid = false;
if (isRemoteConnection(connBean)) {
String url = connBean.getDynamicFields().get(RepositoryConstants.REPOSITORY_URL);
//$NON-NLS-1$
valid = url != null && !"".equals(url);
} else {
valid = Pattern.matches(RepositoryConstants.MAIL_PATTERN, user2);
}
connBean.setComplete(valid);
}
}
ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
repositoryFactory.setRepositoryFactoryFromProvider(RepositoryFactoryProvider.getRepositoriyById(connBean.getRepositoryId()));
if (!connBean.isComplete()) {
return projects;
}
boolean initialized = false;
//$NON-NLS-1$
final String newLine = ":\n";
try {
try {
repositoryFactory.checkAvailability();
} catch (WarningException e) {
String warnings = e.getMessage();
if (warnings != null && !warnings.equals(lastWarnings)) {
lastWarnings = warnings;
if (errorManager != null) {
errorManager.setWarnMessage(warnings);
} else {
final Shell shell = new Shell(DisplayUtils.getDisplay(), SWT.ON_TOP | SWT.TOP);
//$NON-NLS-1$
MessageDialog.openWarning(shell, Messages.getString("LoginComposite.warningTitle"), warnings);
}
}
}
OverTimePopupDialogTask<Boolean> overTimePopupDialogTask = new OverTimePopupDialogTask<Boolean>() {
@Override
public Boolean run() throws Throwable {
ProxyRepositoryFactory.getInstance().initialize();
return null;
}
};
overTimePopupDialogTask.setNeedWaitingProgressJob(false);
overTimePopupDialogTask.runTask();
initialized = true;
} catch (Throwable e) {
projects = new Project[0];
if (errorManager != null) {
//$NON-NLS-1$
errorManager.setErrMessage(Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
} else {
final Shell shell = new Shell(DisplayUtils.getDisplay(), SWT.ON_TOP | SWT.TOP);
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
shell, //$NON-NLS-1$
Messages.getString("LoginComposite.warningTitle"), //$NON-NLS-1$
Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
}
}
if (initialized) {
try {
OverTimePopupDialogTask<Project[]> overTimePopupDialogTask = new OverTimePopupDialogTask<Project[]>() {
@Override
public Project[] run() throws Throwable {
return ProxyRepositoryFactory.getInstance().readProject();
}
};
overTimePopupDialogTask.setNeedWaitingProgressJob(false);
projects = overTimePopupDialogTask.runTask();
Arrays.sort(projects, new Comparator<Project>() {
@Override
public int compare(Project p1, Project p2) {
return p1.getLabel().compareTo(p2.getLabel());
}
});
} catch (PersistenceException e) {
projects = new Project[0];
if (errorManager != null) {
//$NON-NLS-1$
errorManager.setErrMessage(Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
} else {
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
getUsableShell(), //$NON-NLS-1$
Messages.getString("LoginComposite.errorTitle"), //$NON-NLS-1$
Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
}
} catch (BusinessException e) {
projects = new Project[0];
if (errorManager != null) {
//$NON-NLS-1$
errorManager.setErrMessage(Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
} else {
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
getUsableShell(), //$NON-NLS-1$
Messages.getString("LoginComposite.errorTitle"), //$NON-NLS-1$
Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
}
} catch (Throwable e) {
projects = new Project[0];
if (errorManager != null) {
//$NON-NLS-1$
errorManager.setErrMessage(Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
} else {
//$NON-NLS-1$
MessageDialog.openError(//$NON-NLS-1$
getUsableShell(), //$NON-NLS-1$
Messages.getString("LoginComposite.errorTitle"), //$NON-NLS-1$
Messages.getString("LoginComposite.errorMessages1") + newLine + e.getMessage());
}
}
}
return projects;
}
use of org.talend.commons.exception.BusinessException in project tdi-studio-se by Talend.
the class LoginAgreementPage method addListeners.
@Override
public void addListeners() {
acceptButton.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent event) {
try {
LicenseManagement.acceptLicense();
} catch (BusinessException e) {
ErrorDialogWidthDetailArea errorDialog = new ErrorDialogWidthDetailArea(getShell(), RegistrationPlugin.PLUGIN_ID, "", //$NON-NLS-1$
e.getMessage());
System.exit(0);
}
AbstractActionPage iNextPage = getNextPage();
if (iNextPage == null) {
return;
}
try {
gotoNextPage();
} catch (Throwable e1) {
CommonExceptionHandler.process(e1);
}
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
// nothing need to do
}
});
}
use of org.talend.commons.exception.BusinessException in project tdi-studio-se by Talend.
the class ComponentsLocalProviderService method validateComponent.
public boolean validateComponent(String componentFolder, ECodeLanguage language) {
if (componentFolder != null && language != null) {
File folder = new File(componentFolder);
if (folder.exists() && folder.isDirectory()) {
try {
ComponentFileChecker.checkComponentFolder(folder, language.getName().toLowerCase());
// It's ok
return true;
} catch (BusinessException e) {
final BusinessException tempE = e;
Display.getDefault().syncExec(new Runnable() {
public void run() {
Status status = new Status(IStatus.ERROR, CodeGeneratorActivator.PLUGIN_ID, 1, tempE.getMessage(), tempE.getCause());
ErrorDialog dlg = new ErrorDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("ComponentsLocalProviderService.talendExchangeError"), Messages.getString("ComponentsLocalProviderService.componentLoadError"), status, //$NON-NLS-1$ //$NON-NLS-2$
IStatus.ERROR);
dlg.open();
}
});
}
}
}
return false;
}
use of org.talend.commons.exception.BusinessException in project tdi-studio-se by Talend.
the class ComponentsFactory method getComponentsLocation.
/**
* DOC smallet Comment method "checkComponentFolder".
*
* @param currentFolder
* @return
* @throws BusinessException
*/
private File getComponentsLocation(String folder) {
String componentsPath = IComponentsFactory.COMPONENTS_LOCATION;
IBrandingService breaningService = (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
if (breaningService.isPoweredOnlyCamel()) {
componentsPath = IComponentsFactory.CAMEL_COMPONENTS_LOCATION;
}
Bundle b = Platform.getBundle(componentsPath);
File file = null;
try {
URL url = FileLocator.find(b, new Path(folder), null);
if (url == null) {
return null;
}
URL fileUrl = FileLocator.toFileURL(url);
file = new File(fileUrl.getPath());
} catch (Exception e) {
// e.printStackTrace();
ExceptionHandler.process(e);
}
return file;
}
use of org.talend.commons.exception.BusinessException in project tmdm-studio-se by Talend.
the class RenameViewAction method moveToAnotherNode.
public void moveToAnotherNode(IRepositoryViewObject parent, IRepositoryViewObject viewObj) {
MDMServerObjectItem item = (MDMServerObjectItem) viewObj.getProperty().getItem();
waitSomeTime(viewObj);
IProxyRepositoryFactory factory = getFactory();
try {
if (factory.isEditableAndLockIfPossible(item)) {
String path = item.getState().getPath();
IPath ipath = new Path(path);
factory.moveObject(viewObj, ipath);
IRepositoryViewObject iRepositoryViewObject = ContainerCacheService.get(viewObj.getRepositoryObjectType(), path);
commonViewer.refresh(iRepositoryViewObject);
commonViewer.refresh(parent);
}
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} catch (BusinessException e) {
log.error(e.getMessage(), e);
} finally {
try {
factory.unlock(item);
} catch (PersistenceException e) {
log.error(e.getMessage(), e);
} catch (LoginException e) {
log.error(e.getMessage(), e);
}
}
}
Aggregations