Search in sources :

Example 31 with ExportFileResource

use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method getExportPigudfResources.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager#getExportPigudfResources(org.talend
     * .repository.documentation.ExportFileResource[])
     */
@Override
public URL getExportPigudfResources(ExportFileResource[] process) throws ProcessorException {
    List<ExportFileResource> list = new ArrayList<ExportFileResource>();
    //$NON-NLS-1$
    ExportFileResource libResource = new ExportFileResource(null, "");
    // for pigudf
    List<URL> resource = getPigudfResource(process, isOptionChoosed(ExportChoice.needPigudf));
    if (!resource.isEmpty()) {
        return resource.get(0);
    }
    return null;
}
Also used : ExportFileResource(org.talend.repository.documentation.ExportFileResource) ArrayList(java.util.ArrayList) URL(java.net.URL)

Example 32 with ExportFileResource

use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.

the class JavaScriptForESBWithMavenManager method addSourceCodeToExport.

/**
     * DOC nrousseau Comment method "addSourceCodeToExport".
     * 
     * @param list
     * @param processes
     */
private void addSourceCodeToExport(List<ExportFileResource> list, ExportFileResource[] processes, String... codeOptions) {
    List<URL> noUseJustForSimplifyChange = new ArrayList<URL>();
    exportChoice.put(ExportChoice.needSourceCode, Boolean.TRUE);
    exportChoice.put(ExportChoice.needContext, Boolean.TRUE);
    exportChoice.put(ExportChoice.contextName, contextName);
    exportChoice.put(ExportChoice.needMavenScript, Boolean.FALSE);
    processes[0].removeAllMap();
    posExportResource(processes, exportChoice, contextName, launcher, statisticPort, tracePort, 0, (IProcess) null, (ProcessItem) processes[0].getItem(), processes[0].getItem().getProperty().getVersion(), noUseJustForSimplifyChange, codeOptions);
    Map<String, Set<URL>> newResourcesMap = new HashMap<String, Set<URL>>();
    for (String path : processes[0].getRelativePathList()) {
        Set<URL> urls = processes[0].getResourcesByRelativePath(path);
        // put OSGI_INF to /src/main/resources/
        if (path.startsWith(IMavenProperties.SRC_PATH)) {
            newResourcesMap.put(path.replace(IMavenProperties.SRC_PATH, IMavenProperties.MAIN_JAVA_PATH), urls);
        } else {
            newResourcesMap.put(IMavenProperties.MAIN_RESOURCES_PATH + path, urls);
        }
    }
    //$NON-NLS-1$
    ExportFileResource sourceCodeResource = new ExportFileResource(null, "");
    for (String path : newResourcesMap.keySet()) {
        sourceCodeResource.addResources(path, new ArrayList<URL>(newResourcesMap.get(path)));
    }
    list.add(sourceCodeResource);
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) ExportFileResource(org.talend.repository.documentation.ExportFileResource) ArrayList(java.util.ArrayList) URL(java.net.URL)

Example 33 with ExportFileResource

use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.

the class JobJavaScriptsWSManager method getWebXMLFile.

private ExportFileResource getWebXMLFile(Boolean needWebXMLFile) {
    // generate the web.xml file
    //$NON-NLS-1$
    ExportFileResource webInfo = new ExportFileResource(null, "WEB-INF");
    if (!needWebXMLFile) {
        return webInfo;
    }
    List<URL> urlList = new ArrayList<URL>();
    final Bundle b = Platform.getBundle(RepositoryPlugin.PLUGIN_ID);
    try {
        //$NON-NLS-1$
        URL webFileUrl = FileLocator.toFileURL(FileLocator.find(b, new Path("resources/web.xml"), null));
        urlList.add(webFileUrl);
    } catch (MalformedURLException e) {
        ExceptionHandler.process(e);
    } catch (IOException e) {
        ExceptionHandler.process(e);
    }
    webInfo.addResources(urlList);
    return webInfo;
}
Also used : Path(org.eclipse.core.runtime.Path) MalformedURLException(java.net.MalformedURLException) ExportFileResource(org.talend.repository.documentation.ExportFileResource) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) IOException(java.io.IOException) URL(java.net.URL)

Example 34 with ExportFileResource

use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.

the class JobJavaScriptsWSManager method genMetaInfoFolder.

/**
     * DOC x Comment method "genMetaInfoForder".
     * 
     * @param list
     * @return
     */
private ExportFileResource genMetaInfoFolder(Boolean needMetaInfo) {
    ExportFileResource metaInfoResource = new ExportFileResource(null, FileConstants.META_INF_FOLDER_NAME);
    if (!needMetaInfo) {
        return metaInfoResource;
    }
    // generate the MANIFEST.MF file in the temp folder
    String manifestPath = getTmpFolder() + PATH_SEPARATOR + FileConstants.MANIFEST_MF_FILE_NAME;
    Manifest manifest = new Manifest();
    Map<String, Attributes> m = manifest.getEntries();
    Attributes a = new Attributes();
    //$NON-NLS-1$
    a.put(Attributes.Name.IMPLEMENTATION_VERSION, "1.0");
    //$NON-NLS-1$
    a.put(Attributes.Name.IMPLEMENTATION_VENDOR, "Talend Open Studio");
    //$NON-NLS-1$
    m.put("talendWebService", a);
    FileOutputStream fos = null;
    try {
        fos = new FileOutputStream(manifestPath);
        manifest.write(fos);
    } catch (FileNotFoundException e1) {
        ExceptionHandler.process(e1);
    } catch (IOException e1) {
        ExceptionHandler.process(e1);
    } finally {
        if (fos != null) {
            try {
                fos.close();
            } catch (IOException e) {
                ExceptionHandler.process(e);
            }
        }
    }
    List<URL> urlList = new ArrayList<URL>();
    try {
        urlList.add(new File(manifestPath).toURL());
    } catch (MalformedURLException e) {
        ExceptionHandler.process(e);
    }
    metaInfoResource.addResources(urlList);
    return metaInfoResource;
}
Also used : MalformedURLException(java.net.MalformedURLException) Attributes(java.util.jar.Attributes) FileNotFoundException(java.io.FileNotFoundException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) Manifest(java.util.jar.Manifest) URL(java.net.URL) ExportFileResource(org.talend.repository.documentation.ExportFileResource) FileOutputStream(java.io.FileOutputStream) File(java.io.File)

Example 35 with ExportFileResource

use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.

the class JobExportAction method exportJobScript.

private boolean exportJobScript(List<? extends IRepositoryNode> nodes, String version, String bundleVersion, IProgressMonitor monitor) {
    manager.setJobVersion(version);
    manager.setBundleVersion(bundleVersion);
    List<ExportFileResource> processes = getProcesses(nodes, "");
    boolean isNotFirstTime = directoryName != null;
    if (isNotFirstTime && processes != null) {
        for (ExportFileResource process : processes) {
            process.setDirectoryName(directoryName);
        }
    }
    try {
        ProxyRepositoryFactory.getInstance().initialize();
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    ItemCacheManager.clearCache();
    if (!isMultiNodes()) {
        // TODO : bug with export?
        for (ExportFileResource process : processes) {
            process.removeAllMap();
            ProcessItem processItem = (ProcessItem) process.getItem();
            if (!processItem.getProperty().getVersion().equals(version)) {
                // update with the correct version.
                process.setProcess(ItemCacheManager.getProcessItem(processItem.getProperty().getId(), version));
            }
        }
    }
    manager.setProgressMonitor(monitor);
    List<ExportFileResource> resourcesToExport = null;
    try {
        resourcesToExport = manager.getExportResources(processes.toArray(new ExportFileResource[] {}));
        IStructuredSelection selection = new StructuredSelection(nodes);
        // if job has compile error, will not export to avoid problem if run jobscript
        boolean hasErrors = CorePlugin.getDefault().getRunProcessService().checkExportProcess(selection, true);
        if (hasErrors) {
            manager.deleteTempFiles();
            return false;
        }
    } catch (ProcessorException e) {
        MessageBoxExceptionHandler.process(e);
        return false;
    }
    boolean addClasspathJar = true;
    IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
    if (designerCoreUIService != null) {
        addClasspathJar = designerCoreUIService.getPreferenceStore().getBoolean(IRepositoryPrefConstants.ADD_CLASSPATH_JAR);
    }
    if (isMultiNodes() || addClasspathJar) {
        manager.setTopFolder(resourcesToExport);
    }
    doArchiveExport(monitor, resourcesToExport);
    clean();
    ProcessorUtilities.resetExportConfig();
    // no need to regenerate if run in export model
    // boolean generated = generatedCodes(version, monitor, processes);
    // if (!generated) {
    // return false;
    // }
    //$NON-NLS-1$
    monitor.subTask(Messages.getString("JobScriptsExportWizardPage.newExportSuccess", type));
    if (addClasspathJar) {
        reBuildJobZipFile(processes);
    } else {
        String zipFile = getTempDestinationValue();
        String destinationZipFile = manager.getDestinationPath();
        FileCopyUtils.copy(zipFile, destinationZipFile);
    }
    return true;
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) PersistenceException(org.talend.commons.exception.PersistenceException) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Aggregations

ExportFileResource (org.talend.repository.documentation.ExportFileResource)48 URL (java.net.URL)24 ProcessItem (org.talend.core.model.properties.ProcessItem)23 File (java.io.File)20 ArrayList (java.util.ArrayList)19 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)13 ProcessorException (org.talend.designer.runprocess.ProcessorException)11 MalformedURLException (java.net.MalformedURLException)10 IOException (java.io.IOException)8 PersistenceException (org.talend.commons.exception.PersistenceException)8 IFile (org.eclipse.core.resources.IFile)6 Item (org.talend.core.model.properties.Item)6 EList (org.eclipse.emf.common.util.EList)5 HashMap (java.util.HashMap)4 List (java.util.List)4 Set (java.util.Set)4 Path (org.eclipse.core.runtime.Path)4 IProcess (org.talend.core.model.process.IProcess)4 ArchiveFileExportOperationFullPath (org.talend.core.ui.export.ArchiveFileExportOperationFullPath)4 ExportChoice (org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice)4