Search in sources :

Example 1 with SystemException

use of org.talend.commons.exception.SystemException in project tdi-studio-se by Talend.

the class JobErrorsChecker method checkRoutinesCompilationError.

private static void checkRoutinesCompilationError() throws ProcessorException {
    Set<String> dependentRoutines = LastGenerationInfo.getInstance().getRoutinesNeededWithSubjobPerJob(LastGenerationInfo.getInstance().getLastMainJob().getJobId(), LastGenerationInfo.getInstance().getLastMainJob().getJobVersion());
    // from Problems
    List<Problem> errors = Problems.getProblemList().getProblemsBySeverity(ProblemStatus.ERROR);
    for (Problem p : errors) {
        if (p instanceof TalendProblem) {
            TalendProblem talendProblem = (TalendProblem) p;
            if (talendProblem.getType() == ProblemType.ROUTINE && dependentRoutines.contains(talendProblem.getJavaUnitName())) {
                int line = talendProblem.getLineNumber();
                String errorMessage = talendProblem.getDescription();
                throw new ProcessorException(Messages.getString("JobErrorsChecker_routines_compile_errors", talendProblem.getJavaUnitName()) + //$NON-NLS-1$
                '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + line + //$NON-NLS-1$
                '\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + //$NON-NLS-1$
                errorMessage);
            }
        } else {
        // for now not to check components errors when building jobs in studio/commandline
        // throw new ProcessorException(Messages.getString("JobErrorsChecker_jobDesign_errors", p.getType().getTypeName(), //$NON-NLS-1$
        //      p.getJobInfo().getJobName(), p.getComponentName(), p.getDescription()));
        }
    }
    // if can't find the routines problem, try to check the file directly(mainly for commandline)
    try {
        final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
        IProxyRepositoryFactory factory = CorePlugin.getDefault().getProxyRepositoryFactory();
        List<IRepositoryViewObject> routinesObjects = factory.getAll(ERepositoryObjectType.ROUTINES, false);
        if (routinesObjects != null) {
            for (IRepositoryViewObject obj : routinesObjects) {
                Property property = obj.getProperty();
                if (!dependentRoutines.contains(property.getLabel())) {
                    continue;
                }
                Item routinesitem = property.getItem();
                IFile routinesFile = synchronizer.getFile(routinesitem);
                IMarker[] markers = routinesFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
                for (IMarker marker : markers) {
                    Integer lineNr = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
                    String message = (String) marker.getAttribute(IMarker.MESSAGE);
                    Integer severity = (Integer) marker.getAttribute(IMarker.SEVERITY);
                    Integer start = (Integer) marker.getAttribute(IMarker.CHAR_START);
                    Integer end = (Integer) marker.getAttribute(IMarker.CHAR_END);
                    if (lineNr != null && message != null && severity != null && start != null && end != null) {
                        switch(severity) {
                            case IMarker.SEVERITY_ERROR:
                                throw new ProcessorException(//$NON-NLS-1$
                                Messages.getString("JobErrorsChecker_routines_compile_errors", property.getLabel()) + '\n' + Messages.getString("JobErrorsChecker_compile_error_line") + ':' + ' ' + lineNr + //$NON-NLS-1$
                                '\n' + Messages.getString("JobErrorsChecker_compile_error_detailmessage") + ':' + ' ' + //$NON-NLS-1$
                                message);
                            default:
                                break;
                        }
                    }
                }
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    } catch (SystemException e) {
        ExceptionHandler.process(e);
    } catch (CoreException e) {
        ExceptionHandler.process(e);
    }
}
Also used : ITalendSynchronizer(org.talend.designer.codegen.ITalendSynchronizer) IFile(org.eclipse.core.resources.IFile) TalendProblem(org.talend.core.model.process.TalendProblem) Item(org.talend.core.model.properties.Item) SystemException(org.talend.commons.exception.SystemException) CoreException(org.eclipse.core.runtime.CoreException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) TalendProblem(org.talend.core.model.process.TalendProblem) Problem(org.talend.core.model.process.Problem) IMarker(org.eclipse.core.resources.IMarker) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 2 with SystemException

use of org.talend.commons.exception.SystemException in project tdi-studio-se by Talend.

the class CreateSqlpatternAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    RepositoryNode sqlPatternNode = null;
    if (!isFromSqlPatternComposite) {
        sqlPatternNode = getCurrentRepositoryNode();
    }
    if (isToolbar()) {
        if (sqlPatternNode != null && sqlPatternNode.getContentType() != ERepositoryObjectType.SQLPATTERNS) {
            sqlPatternNode = null;
        }
        if (sqlPatternNode == null) {
            sqlPatternNode = getRepositoryNodeForDefault(ERepositoryObjectType.SQLPATTERNS);
        }
    }
    RepositoryNode node = null;
    IPath path;
    if (this.sqlPatternPath != null) {
        path = new Path(this.sqlPatternPath);
    } else if (isToolbar()) {
        path = RepositoryNodeUtilities.getPath(sqlPatternNode);
    } else {
        ISelection selection = getSelection();
        Object obj = ((IStructuredSelection) selection).getFirstElement();
        node = (RepositoryNode) obj;
        path = RepositoryNodeUtilities.getPath(node);
    }
    NewSqlpatternWizard routineWizard = new NewSqlpatternWizard(path);
    WizardDialog dlg = new WizardDialog(Display.getCurrent().getActiveShell(), routineWizard);
    if (dlg.open() == Window.OK) {
        try {
            openSQLPatternEditor(routineWizard.getSQLPattern(), false);
        } catch (PartInitException e) {
            MessageBoxExceptionHandler.process(e);
        } catch (SystemException e) {
            MessageBoxExceptionHandler.process(e);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) SystemException(org.talend.commons.exception.SystemException) NewSqlpatternWizard(org.talend.repository.ui.wizards.sqlpattern.NewSqlpatternWizard) ISelection(org.eclipse.jface.viewers.ISelection) PartInitException(org.eclipse.ui.PartInitException) RepositoryNode(org.talend.repository.model.RepositoryNode) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Example 3 with SystemException

use of org.talend.commons.exception.SystemException in project tdi-studio-se by Talend.

the class EditSqlpatternAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
protected void doRun() {
    RepositoryNode node = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
    Property property = node.getObject().getProperty();
    Property updatedProperty = null;
    try {
        updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(property.getItem())), property.getId()).getProperty();
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    // update the property of the node repository object
    // node.getObject().setProperty(updatedProperty);
    SQLPatternItem sqlPatternItem = (SQLPatternItem) node.getObject().getProperty().getItem();
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean readonly = factory.getStatus(sqlPatternItem) == ERepositoryStatus.LOCK_BY_OTHER;
    try {
        openSQLPatternEditor(sqlPatternItem, readonly);
    // TDI-21143 : Studio repository view : remove all refresh call to repo view
    // IRepositoryView view = getViewPart();
    // if (view != null) {
    // view.refresh(node);
    // }
    } catch (PartInitException e) {
        MessageBoxExceptionHandler.process(e);
    } catch (SystemException e) {
        MessageBoxExceptionHandler.process(e);
    }
}
Also used : Project(org.talend.core.model.general.Project) SystemException(org.talend.commons.exception.SystemException) PersistenceException(org.talend.commons.exception.PersistenceException) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) PartInitException(org.eclipse.ui.PartInitException) RepositoryNode(org.talend.repository.model.RepositoryNode) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 4 with SystemException

use of org.talend.commons.exception.SystemException in project tdi-studio-se by Talend.

the class ShadowNode method getGeneratedCode.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.model.process.INode#getGeneratedCode()
     */
public String getGeneratedCode() {
    String generatedCode;
    try {
        ICodeGeneratorService service = RunProcessPlugin.getDefault().getCodeGeneratorService();
        generatedCode = service.createCodeGenerator().generateComponentCode(this, ECodePart.MAIN);
    } catch (SystemException e) {
        generatedCode = null;
    }
    return generatedCode;
}
Also used : SystemException(org.talend.commons.exception.SystemException) ICodeGeneratorService(org.talend.designer.codegen.ICodeGeneratorService)

Example 5 with SystemException

use of org.talend.commons.exception.SystemException in project tdi-studio-se by Talend.

the class LoginHelper method loginAuto.

public boolean loginAuto() {
    ConnectionBean connBean = getConnection();
    User user = getUser(connBean);
    // must have this init, used to retreive projects
    setRepositoryContextInContext(connBean, user, null, null);
    boolean isRemoteConnection = LoginHelper.isRemoteConnection(connBean);
    if (isRemoteConnection) {
        boolean isStudioNeedUpdate = false;
        try {
            isStudioNeedUpdate = isStudioNeedUpdate(connBean);
        } catch (SystemException e) {
            isStudioNeedUpdate = false;
        }
        if (isStudioNeedUpdate) {
            return false;
        }
    }
    Project lastUsedProject = getLastUsedProject(getProjects(connBean));
    if (lastUsedProject == null) {
        return false;
    }
    String lastUsedBranch = null;
    if (isRemoteConnection) {
        if (svnProviderService != null) {
            String projectUrl = svnProviderService.getProjectUrl(lastUsedProject);
            String projectName = lastUsedProject.getTechnicalLabel();
            lastUsedBranch = prefManipulator.getLastSVNBranch(projectUrl, projectName);
        }
        List<String> branches = null;
        try {
            branches = getProjectBranches(lastUsedProject);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if (branches == null || branches.isEmpty()) {
            return false;
        }
        if (!branches.contains(lastUsedBranch)) {
            MessageDialog.openError(getUsableShell(), Messages.getString("LoginHelper.errorTitle"), //$NON-NLS-1$ //$NON-NLS-2$
            Messages.getString("LoginHelper.branchChanged"));
            return false;
        }
    }
    setRepositoryContextInContext(connBean, user, lastUsedProject, lastUsedBranch);
    return logIn(connBean, lastUsedProject);
}
Also used : Project(org.talend.core.model.general.Project) User(org.talend.core.model.properties.User) SystemException(org.talend.commons.exception.SystemException) JSONException(org.talend.utils.json.JSONException) ConnectionBean(org.talend.core.model.general.ConnectionBean)

Aggregations

SystemException (org.talend.commons.exception.SystemException)24 IFile (org.eclipse.core.resources.IFile)10 PartInitException (org.eclipse.ui.PartInitException)9 CoreException (org.eclipse.core.runtime.CoreException)6 PersistenceException (org.talend.commons.exception.PersistenceException)6 IOException (java.io.IOException)5 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 Property (org.talend.core.model.properties.Property)5 ICodeGeneratorService (org.talend.designer.codegen.ICodeGeneratorService)5 RepositoryNode (org.talend.repository.model.RepositoryNode)5 File (java.io.File)4 RoutineItem (org.talend.core.model.properties.RoutineItem)4 FileOutputStream (java.io.FileOutputStream)3 IPath (org.eclipse.core.runtime.IPath)3 ISelection (org.eclipse.jface.viewers.ISelection)3 WizardDialog (org.eclipse.jface.wizard.WizardDialog)3 Project (org.talend.core.model.general.Project)3 Item (org.talend.core.model.properties.Item)3 SQLPatternItem (org.talend.core.model.properties.SQLPatternItem)3 BufferedInputStream (java.io.BufferedInputStream)2