Search in sources :

Example 1 with ProcessorException

use of org.talend.designer.runprocess.ProcessorException in project tdi-studio-se by Talend.

the class RepositoryService method exportPigudf.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.model.IRepositoryService#exportPigudf(org.talend.designer.runprocess.IProcessor,
     * org.talend.core.model.properties.Property, int, int)
     */
@Override
public String exportPigudf(IProcessor processor, Property property, boolean isExport) throws ProcessorException {
    // build java project
    CorePlugin.getDefault().getRunProcessService().buildJavaProject();
    Map<ExportChoice, Object> exportChoiceMap = new EnumMap<ExportChoice, Object>(ExportChoice.class);
    exportChoiceMap.put(ExportChoice.needPigudf, true);
    ProcessItem processItem = (ProcessItem) property.getItem();
    ExportFileResource fileResource = new ExportFileResource(processItem, property.getLabel());
    ExportFileResource[] exportFileResources = new ExportFileResource[] { fileResource };
    IContext context = processor.getContext();
    //$NON-NLS-1$
    String contextName = "Default";
    if (context != null) {
        contextName = context.getName();
    }
    JobScriptsManager jobScriptsManager = JobScriptsManagerFactory.createManagerInstance(exportChoiceMap, contextName, JobScriptsManager.ALL_ENVIRONMENTS, -1, -1, JobExportType.POJO);
    URL url = jobScriptsManager.getExportPigudfResources(exportFileResources);
    if (url == null) {
        return null;
    }
    File file = new File(url.getFile());
    // String librariesPath = LibrariesManagerUtils.getLibrariesPath(ECodeLanguage.JAVA) + "/";
    //$NON-NLS-1$
    String librariesPath = processor.getCodeProject().getLocation() + "/lib/";
    String targetFileName = JobJavaScriptsManager.USERPIGUDF_JAR;
    if (!isExport) {
        targetFileName = property.getLabel() + '_' + property.getVersion() + '_' + JobJavaScriptsManager.USERPIGUDF_JAR;
    }
    File target = new File(librariesPath + targetFileName);
    try {
        FilesUtils.copyFile(file, target);
    } catch (IOException e) {
        throw new ProcessorException(e.getMessage());
    }
    return targetFileName;
}
Also used : IContext(org.talend.core.model.process.IContext) JobScriptsManager(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager) ProcessorException(org.talend.designer.runprocess.ProcessorException) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice) IOException(java.io.IOException) URL(java.net.URL) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) JSONObject(org.talend.utils.json.JSONObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) SalesforceModuleRepositoryObject(org.talend.core.repository.model.repositoryObject.SalesforceModuleRepositoryObject) EnumMap(java.util.EnumMap) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 2 with ProcessorException

use of org.talend.designer.runprocess.ProcessorException in project tdi-studio-se by Talend.

the class HTMLDocGenerator method generateSourceCodeInfo.

/**
     * DOC qwei Comment method "generateSourceCodeInfo".
     */
private void generateSourceCodeInfo(ProcessItem item, Element element) {
    if (CorePlugin.getDefault().getPreferenceStore().getBoolean(ITalendCorePrefConstants.DOC_GENERATESOURCECODE)) {
        IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
        IProcess process = service.getProcessFromProcessItem(item);
        IProcessor processor = ProcessorUtilities.getProcessor(process, null, process.getContextManager().getDefaultContext());
        // hidePasswordInSourceCode4Doc(process);
        try {
            processor.cleanBeforeGenerate(TalendProcessOptionConstants.CLEAN_JAVA_CODES | TalendProcessOptionConstants.CLEAN_CONTEXTS | TalendProcessOptionConstants.CLEAN_DATA_SETS);
            processor.generateCode(false, true, false);
        } catch (ProcessorException e) {
            ExceptionHandler.process(e);
        }
        //$NON-NLS-1$
        Element sourceCodeInfoElement = DocumentHelper.createElement("sourcecodes");
        ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
        // StringBuffer componentsCode = new StringBuffer();
        try {
            IFile codeFile = synchronizer.getFile(item);
            if (codeFile == null) {
                return;
            }
            //$NON-NLS-1$
            String tempStr = "";
            InputStream in = codeFile.getContents();
            BufferedReader buffer = new BufferedReader(new InputStreamReader(in));
            while ((tempStr = buffer.readLine()) != null) {
                //$NON-NLS-1$
                Element codeElement = DocumentHelper.createElement("code");
                // componentsCode.append(tempStr).append("\n");
                //$NON-NLS-1$
                codeElement.addAttribute("content", tempStr);
                sourceCodeInfoElement.add(codeElement);
            }
            buffer.close();
            in.close();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            // e.printStackTrace();
            ExceptionHandler.process(e);
        }
        element.add(sourceCodeInfoElement);
    }
}
Also used : ITalendSynchronizer(org.talend.designer.codegen.ITalendSynchronizer) ProcessorException(org.talend.designer.runprocess.ProcessorException) IFile(org.eclipse.core.resources.IFile) InputStreamReader(java.io.InputStreamReader) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Element(org.dom4j.Element) BufferedReader(java.io.BufferedReader) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcessor(org.talend.designer.runprocess.IProcessor) IProcess(org.talend.core.model.process.IProcess) TransformerException(javax.xml.transform.TransformerException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) ProcessorException(org.talend.designer.runprocess.ProcessorException) MalformedURLException(java.net.MalformedURLException) PersistenceException(org.talend.commons.exception.PersistenceException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException)

Example 3 with ProcessorException

use of org.talend.designer.runprocess.ProcessorException in project tdi-studio-se by Talend.

the class JobJavaScriptOSGIForESBManager method getExportResources.

@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] processes, String... codeOptions) throws ProcessorException {
    List<ExportFileResource> list = new ArrayList<ExportFileResource>();
    //$NON-NLS-1$;
    ExportFileResource osgiResource = new ExportFileResource(null, "");
    //$NON-NLS-1$
    ExportFileResource jobScriptResource = new ExportFileResource(null, "");
    list.add(osgiResource);
    list.add(jobScriptResource);
    // set export config mode now only to be sure that the libraries will be
    // setup for an export mode, and not
    // editor mode.
    //$NON-NLS-1$
    ProcessorUtilities.setExportConfig(JAVA, "", "");
    // set export type as osgi
    ProcessorUtilities.setExportAsOSGI(true);
    try {
        ProcessItem processItem = null;
        for (ExportFileResource process : processes) {
            processItem = (ProcessItem) process.getItem();
            if (processItem.eIsProxy() || processItem.getProcess().eIsProxy()) {
                try {
                    Property property = ProxyRepositoryFactory.getInstance().getUptodateProperty(processItem.getProperty());
                    processItem = (ProcessItem) property.getItem();
                } catch (PersistenceException e) {
                    throw new ProcessorException(e);
                }
            }
            String jobVersion = processItem.getProperty().getVersion();
            if (!isMultiNodes() && getSelectedJobVersion() != null) {
                jobVersion = getSelectedJobVersion();
            }
            ProcessorUtilities.setExportConfig(process.getDirectoryName(), true);
            String processId = processItem.getProperty().getId();
            if (null == contextName) {
                contextName = processItem.getProcess().getDefaultContext();
            }
            IProcess iProcess = generateJobFiles(processItem, contextName, jobVersion, statisticPort != IProcessor.NO_STATISTICS, tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
            analysisModules(processId, jobVersion);
            analysisMavenModule(processItem);
            // generate jar file for job
            getJobScriptsUncompressed(jobScriptResource, processItem);
            // dynamic DB XML mapping
            addXmlMapping(process, isOptionChoosed(ExportChoice.needSourceCode));
            generateConfig(osgiResource, processItem, iProcess);
            addResources(osgiResource, processItem);
            /*
                 * export current item's dependencies. this used for TDM components specially and need more discussion
                 * about then
                 */
            BuildExportManager.getInstance().exportOSGIDependencies(osgiResource, processItem);
        }
        ExportFileResource libResource = getCompiledLibExportFileResource(processes);
        list.add(libResource);
        // generate the META-INFO folder
        ExportFileResource metaInfoFolder = genMetaInfoFolder(libResource, processItem);
        list.add(0, metaInfoFolder);
        ExportFileResource providedLibResources = getProvidedLibExportFileResource(processes);
        if (providedLibResources != null) {
            list.add(providedLibResources);
        }
    } catch (ProcessorException e) {
        throw e;
    } catch (Exception e) {
        throw new ProcessorException(e);
    }
    return list;
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) ArrayList(java.util.ArrayList) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) IProcess(org.talend.core.model.process.IProcess) ProcessorException(org.talend.designer.runprocess.ProcessorException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 4 with ProcessorException

use of org.talend.designer.runprocess.ProcessorException in project tesb-studio-se by Talend.

the class RunContainerProcessor method run.

@Override
public Process run(int statisticsPort, int tracePort, String watchParam, String log4jLevel, IProgressMonitor monitor, IProcessMessageManager processMessageManager) throws ProcessorException {
    if (!RuntimeServerController.getInstance().isRunning()) {
        try {
            new StartRuntimeProgress(true).run(monitor);
            new CheckingBundlesProgress().run(monitor);
        } catch (Exception e) {
            throw new ProcessorException(RunContainerMessages.getString("StartRuntimeAction.ErrorStart"), e);
        }
    }
    if (RuntimeServerController.getInstance().isRunning()) {
        RunESBRuntimeProcess esbRunContainerProcess = new RunESBRuntimeProcess(process, statisticsPort, tracePort, monitor);
        esbRunContainerProcess.setMessageManager(processMessageManager);
        try {
            esbRunContainerProcess.start();
        } catch (Exception e) {
            throw new ProcessorException(e);
        }
        return esbRunContainerProcess;
    } else {
        throw new ProcessorException(RunContainerMessages.getString("StartRuntimeAction.ErrorStart"));
    }
}
Also used : StartRuntimeProgress(org.talend.designer.esb.runcontainer.ui.progress.StartRuntimeProgress) ProcessorException(org.talend.designer.runprocess.ProcessorException) CheckingBundlesProgress(org.talend.designer.esb.runcontainer.ui.progress.CheckingBundlesProgress) ProcessorException(org.talend.designer.runprocess.ProcessorException)

Example 5 with ProcessorException

use of org.talend.designer.runprocess.ProcessorException in project tdi-studio-se by Talend.

the class PublishOnSpagoExportWizardPage method finish.

/**
     * The Finish button was pressed. Try to do the required work now and answer a boolean indicating success. If false
     * is returned then the wizard will not close.
     * 
     * @returns boolean
     */
public boolean finish() {
    Map<ExportChoice, Object> exportChoiceMap = getExportChoiceMap();
    boolean canExport = false;
    for (ExportChoice choice : ExportChoice.values()) {
        if (exportChoiceMap.get(choice) != null && exportChoiceMap.get(choice) instanceof Boolean && (Boolean) exportChoiceMap.get(choice)) {
            canExport = true;
            break;
        }
    }
    if (!canExport) {
        MessageDialog.openInformation(getContainer().getShell(), //$NON-NLS-1$
        Messages.getString("PublishOnSpagoExportWizardPage.publishResourceError"), //$NON-NLS-1$
        Messages.getString("PublishOnSpagoExportWizardPage.chooseResource"));
        return false;
    }
    if (!ensureTargetIsValid()) {
        return false;
    }
    String topFolder = getRootFolderName();
    manager = new //$NON-NLS-1$
    JobJavaScriptsManager(//$NON-NLS-1$
    exportChoiceMap, //$NON-NLS-1$
    contextCombo.getText(), //$NON-NLS-1$
    "all", //$NON-NLS-1$
    IProcessor.NO_STATISTICS, IProcessor.NO_TRACES);
    List<ExportFileResource> resourcesToExport = null;
    try {
        resourcesToExport = getExportResources();
    } catch (ProcessorException e) {
        MessageBoxExceptionHandler.process(e);
        return false;
    }
    setTopFolder(resourcesToExport, topFolder);
    // Save dirty editors if possible but do not stop if not all are saved
    saveDirtyEditors();
    // about to invoke the operation so save our state
    saveWidgetValues();
    // boolean ok = executeExportOperation(new ArchiveFileExportOperationFullPath(process));
    ArchiveFileExportOperationFullPath exporterOperation = getExporterOperation(resourcesToExport);
    boolean ok = executeExportOperation(exporterOperation);
    // path can like name/name
    manager.deleteTempFiles();
    ProcessorUtilities.resetExportConfig();
    for (int i = 0; i < process.length; i++) {
        ProcessItem processItem = (ProcessItem) process[i].getItem();
        try {
            ProcessorUtilities.generateCode(processItem, processItem.getProcess().getDefaultContext(), false, false);
        } catch (ProcessorException e) {
            ExceptionHandler.process(e);
        }
    }
    // cantoine : connection to SpagoBiEngineClient to publish Job.
    try {
        Project project = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject();
        // retrieve user, password, host, port from selected SpagoBiServer
        String selectedSpagoBiEngineName = serverSpagoBi.getItem(serverSpagoBi.getSelectionIndex());
        SpagoBiServer spagoBiServer = null;
        List<SpagoBiServer> listServerSapgo = null;
        // ProxyRepositoryFactory proxyRepositoryFactory = ProxyRepositoryFactory.getInstance();
        // try {
        listServerSapgo = SpagoBiServerHelper.parse(new SpagoBiPreferencePage().getPreferenceStore().getString(SpagoBiServer.SPAGOBI_SERVER));
        if (listServerSapgo != null && !listServerSapgo.isEmpty()) {
            Iterator<SpagoBiServer> iterator = listServerSapgo.iterator();
            while (iterator.hasNext()) {
                spagoBiServer = iterator.next();
                if (spagoBiServer.getEngineName().equals(selectedSpagoBiEngineName)) {
                    break;
                }
            }
        }
        // } catch (PersistenceException e) {
        // displayErrorDialog(e.getMessage());
        // }
        // "biadmin";
        String user = spagoBiServer.getLogin();
        // "biadmin";
        String password = spagoBiServer.getPassword();
        String host = spagoBiServer.getHost();
        String port = spagoBiServer.getPort();
        // create the client
        //$NON-NLS-1$
        ISpagoBITalendEngineClient client = new SpagoBITalendEngineClient(user, password, host, port, "SpagoBITalendEngine");
        // get some informations about the engine instance referenced by the client
        //$NON-NLS-1$
        System.out.println("Engine version: " + client.getEngineVersion());
        //$NON-NLS-1$
        System.out.println("Engine fullname: " + client.getEngineName());
        // prepare parameters used during deployment
        JobDeploymentDescriptor jobDeploymentDescriptor = new JobDeploymentDescriptor(project.getLabel(), project.getLanguage().getName());
        File zipFile = new File(getDestinationValue());
        // deploy job on engine runtime
        boolean result = client.deployJob(jobDeploymentDescriptor, zipFile);
        if (result)
            //$NON-NLS-1$
            System.out.println("Jobs deployed succesfully");
        else
            //$NON-NLS-1$
            System.out.println("Jobs not deployed");
    } catch (EngineUnavailableException e) {
        //$NON-NLS-1$
        System.err.println("ERROR: " + e.getMessage());
    } catch (AuthenticationFailedException e) {
        //$NON-NLS-1$
        System.err.println("ERROR: " + e.getMessage());
    } catch (UnsupportedEngineVersionException e) {
        //$NON-NLS-1$
        System.err.println("ERROR: Unsupported engine version");
        System.err.println(//$NON-NLS-1$
        "You are using TalendEngineClientAPI version " + SpagoBITalendEngineClient.CLIENTAPI_VERSION_NUMBER + //$NON-NLS-1$
        ". " + //$NON-NLS-1$
        "The TalendEngine instance you are trying to connect to require TalendEngineClientAPI version " + e.getComplianceVersion() + //$NON-NLS-1$
        " or grater.");
    } catch (ServiceInvocationFailedException e) {
        //$NON-NLS-1$
        System.err.println("ERROR: " + e.getMessage());
        //$NON-NLS-1$ //$NON-NLS-2$
        System.err.println("StatusLine: " + e.getStatusLine() + "responseBody: " + e.getResponseBody());
    }
    return ok;
// return true;
}
Also used : SpagoBiServer(org.talend.core.model.properties.SpagoBiServer) ServiceInvocationFailedException(it.eng.spagobi.engines.talend.client.exception.ServiceInvocationFailedException) RepositoryContext(org.talend.core.context.RepositoryContext) JobDeploymentDescriptor(it.eng.spagobi.engines.talend.client.JobDeploymentDescriptor) AuthenticationFailedException(it.eng.spagobi.engines.talend.client.exception.AuthenticationFailedException) ISpagoBITalendEngineClient(it.eng.spagobi.engines.talend.client.ISpagoBITalendEngineClient) SpagoBITalendEngineClient(it.eng.spagobi.engines.talend.client.SpagoBITalendEngineClient) SpagoBiPreferencePage(org.talend.sbi.engines.client.ui.preferences.SpagoBiPreferencePage) ProcessorException(org.talend.designer.runprocess.ProcessorException) UnsupportedEngineVersionException(it.eng.spagobi.engines.talend.client.exception.UnsupportedEngineVersionException) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice) Project(org.talend.core.model.general.Project) EngineUnavailableException(it.eng.spagobi.engines.talend.client.exception.EngineUnavailableException) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ISpagoBITalendEngineClient(it.eng.spagobi.engines.talend.client.ISpagoBITalendEngineClient) File(java.io.File) ArchiveFileExportOperationFullPath(org.talend.core.ui.export.ArchiveFileExportOperationFullPath)

Aggregations

ProcessorException (org.talend.designer.runprocess.ProcessorException)43 IOException (java.io.IOException)15 File (java.io.File)11 CoreException (org.eclipse.core.runtime.CoreException)11 ProcessItem (org.talend.core.model.properties.ProcessItem)11 IProcessor (org.talend.designer.runprocess.IProcessor)11 CsvArray (org.talend.core.utils.CsvArray)10 IContext (org.talend.core.model.process.IContext)9 Status (org.eclipse.core.runtime.Status)8 IProcess (org.talend.core.model.process.IProcess)8 ExportFileResource (org.talend.repository.documentation.ExportFileResource)8 IFile (org.eclipse.core.resources.IFile)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)5 PersistenceException (org.talend.commons.exception.PersistenceException)5 ExportChoice (org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ArrayList (java.util.ArrayList)4 IStatus (org.eclipse.core.runtime.IStatus)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4