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;
}
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);
}
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;
}
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;
}
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;
}
Aggregations