use of org.talend.repository.documentation.ExportFileResource in project tesb-studio-se by Talend.
the class ExportServiceWithMavenAction method addMavenFilesToExport.
private void addMavenFilesToExport(IProgressMonitor monitor) throws Throwable {
manager.setDestinationPath(serviceManager.getDestinationPath());
String tempDestinationPath = getTempDestinationValue();
List<ExportFileResource> resourcesToExport = manager.getExportResources(//$NON-NLS-1$
new ExportFileResource[] { new ExportFileResource(serviceItem, "") });
ArchiveFileExportOperationFullPath exporterOperation = new ArchiveFileExportOperationFullPath(resourcesToExport, tempDestinationPath);
manager.setTopFolder(resourcesToExport);
executeExportOperation(exporterOperation, monitor);
ZipToFile.unZipFile(tempDestinationPath, tempFolder);
FilesUtils.removeFile(new File(tempDestinationPath));
}
use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class JobJavaScriptsWSManager method getExportResources.
/*
* (non-Javadoc)
*
* @see org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobJavaScriptsManager#getExportResources
* (org.talend.repository.ui.wizards.exportjob.ExportFileResource[], java.util.Map, java.lang.String,
* java.lang.String, int, int, java.lang.String[])
*/
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] process, String... codeOptions) throws ProcessorException {
List<ExportFileResource> list = new ArrayList<ExportFileResource>();
boolean needJob = true;
boolean needSource = isOptionChoosed(ExportChoice.needSourceCode);
boolean needContext = isOptionChoosed(ExportChoice.needContext);
//$NON-NLS-1$
ExportFileResource libResource = new ExportFileResource(null, "WEB-INF/lib");
//$NON-NLS-1$
ExportFileResource contextResource = new ExportFileResource(null, "WEB-INF/classes");
//$NON-NLS-1$
ExportFileResource srcResource = new ExportFileResource(null, "WEB-INF");
if (needJob) {
list.add(libResource);
}
if (needContext) {
list.add(contextResource);
}
if (needSource) {
list.add(srcResource);
}
copyServerConfigFileToTempDir();
// 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", "", "");
for (ExportFileResource exportResource : process) {
ProcessItem processItem = (ProcessItem) exportResource.getItem();
String selectedJobVersion = processItem.getProperty().getVersion();
if (!isMultiNodes() && this.getSelectedJobVersion() != null) {
selectedJobVersion = this.getSelectedJobVersion();
}
if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
generateJobFiles(processItem, contextName, selectedJobVersion, statisticPort != IProcessor.NO_STATISTICS, tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
}
}
// Gets talend libraries
List<URL> talendLibraries = getExternalLibraries(true, process);
libResource.addResources(talendLibraries);
// Add log4j files if needed
if (Log4jPrefsSettingManager.getInstance().isLog4jEnable()) {
addLog4jXmlToRes(contextResource);
}
for (ExportFileResource proces : process) {
ProcessItem processItem = (ProcessItem) proces.getItem();
String selectedJobVersion = processItem.getProperty().getVersion();
if (!isMultiNodes() && this.getSelectedJobVersion() != null) {
selectedJobVersion = this.getSelectedJobVersion();
}
ProcessorUtilities.setExportConfig(proces.getDirectoryName(), true);
// if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
// generateJobFiles(processItem, contextName, selectedJobVersion, statisticPort != IProcessor.NO_STATISTICS,
// tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
// }
// generate the WSDL file
ExportFileResource wsdlFile = getWSDLFile(processItem, isOptionChoosed(ExportChoice.needWSDL), talendLibraries);
list.add(wsdlFile);
// edit the WSDD file
editWSDDFile(processItem);
// add children jobs
boolean needChildren = true;
addSubJobResources(process, processItem, needChildren, exportChoice, libResource, contextResource, srcResource, selectedJobVersion);
// generate the context file
getContextScripts(processItem, needContext, contextResource, selectedJobVersion);
// generate jar file for job
libResource.addResources(getJobScripts(processItem, selectedJobVersion, needJob));
// dynamic db xml mapping
addXmlMapping(proces, isOptionChoosed(ExportChoice.needSourceCode));
}
// generate Server Config file
ExportFileResource serverConfigFile = getServerConfigFile(isOptionChoosed(ExportChoice.needCONFIGFILE));
list.add(serverConfigFile);
// generate the WSDD file
ExportFileResource wsddFile = getWSDDFile(isOptionChoosed(ExportChoice.needWSDD));
list.add(wsddFile);
// generate the WEB-INFO folder
ExportFileResource webInfoFolder = getWebXMLFile(isOptionChoosed(ExportChoice.needWEBXML));
list.add(webInfoFolder);
// generate the META-INFO folder
ExportFileResource metaInfoFolder = genMetaInfoFolder(isOptionChoosed(ExportChoice.needMetaInfo));
list.add(metaInfoFolder);
// Gets system routines
List<URL> systemRoutineList = getSystemRoutine(process);
libResource.addResources(systemRoutineList);
// Gets user routines
List<URL> userRoutineList = getUserRoutine(process);
libResource.addResources(userRoutineList);
// Gets axis libraries
List<ModuleNeeded> newAxisLib = new ArrayList<ModuleNeeded>(axisLib);
for (URL libUrl : talendLibraries) {
if (libUrl.getFile() != null) {
newAxisLib.remove(new File(libUrl.getFile()).getName());
}
}
List<URL> axisLibList = getLib(newAxisLib, isOptionChoosed(ExportChoice.needAXISLIB));
libResource.addResources(axisLibList);
return list;
}
use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getExportResources.
/*
* (non-Javadoc)
*
* @see
* org.talend.repository.ui.wizards.exportjob.JobScriptsManager#getExportResources(org.talend.core.model.properties
* .ProcessItem[], boolean, boolean, boolean, boolean, boolean, boolean, boolean, java.lang.String)
*/
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] process, String... codeOptions) throws ProcessorException {
exportFileResource = process;
for (int i = 0; i < process.length; i++) {
ProcessItem processItem = (ProcessItem) process[i].getItem();
String selectedJobVersion = processItem.getProperty().getVersion();
selectedJobVersion = preExportResource(process, i, selectedJobVersion);
IProcess jobProcess = null;
// code is just kept like this to avoid too big changes right now.
if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
if (contextName != null) {
jobProcess = generateJobFiles(processItem, contextName, selectedJobVersion, statisticPort != IProcessor.NO_STATISTICS || isOptionChoosed(ExportChoice.addStatistics), tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
}
analysisModules(processItem.getProperty().getId(), selectedJobVersion);
} else {
LastGenerationInfo.getInstance().setModulesNeededWithSubjobPerJob(processItem.getProperty().getId(), processItem.getProperty().getVersion(), Collections.<ModuleNeeded>emptySet());
LastGenerationInfo.getInstance().setLastMainJob(null);
}
List<URL> resources = new ArrayList<URL>();
List<URL> childrenList = new ArrayList<URL>();
if (CommonsPlugin.isHeadless()) {
childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, codeOptions);
} else {
String log4jOption = getLog4jLevel() != null ? TalendProcessArgumentConstant.CMD_ARG_LOG4J_LEVEL + getLog4jLevel().toLowerCase() : null;
String[] newCodeOptions = codeOptions;
if (!ArrayUtils.contains(codeOptions, log4jOption)) {
newCodeOptions = (String[]) ArrayUtils.add(codeOptions, log4jOption);
}
childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, newCodeOptions);
}
resources.addAll(childrenList);
process[i].addResources(resources);
// Gets job designer resouce
// List<URL> srcList = getSource(processItem, exportChoice.get(ExportChoice.needSource));
// process[i].addResources(JOB_SOURCE_FOLDER_NAME, srcList);
}
// Exports the system libs
List<ExportFileResource> list = new ArrayList<ExportFileResource>(Arrays.asList(process));
// Add the java system libraries
ExportFileResource libResource = getCompiledLibExportFileResource(process);
list.add(libResource);
// Gets jobInfo.properties
// only addClasspathJar not check in preferences ,then export the jobInfo.properties
boolean addClasspathJar = false;
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
addClasspathJar = designerCoreUIService.getPreferenceStore().getBoolean(IRepositoryPrefConstants.ADD_CLASSPATH_JAR);
}
if (!addClasspathJar) {
if (!(process.length > 1)) {
for (ExportFileResource pro : process) {
ExportFileResource jobInfoResource = new ExportFileResource(null, PATH_SEPARATOR);
if (CommonsPlugin.isHeadless()) {
jobInfoResource = new ExportFileResource();
}
list.add(jobInfoResource);
List<URL> jobInfoList = getJobInfoFile(pro, contextName);
jobInfoResource.addResources(jobInfoList);
}
}
}
if (PluginChecker.isRulesPluginLoaded()) {
// hywang add for 6484,add final drl files or xls files to exported job script
//$NON-NLS-1$
ExportFileResource ruleFileResource = new ExportFileResource(null, "Rules/rules/final");
list.add(ruleFileResource);
try {
Map<String, List<URL>> map = initUrlForRulesFiles(process);
Object[] keys = map.keySet().toArray();
for (Object key : keys) {
List<URL> talendDrlFiles = map.get(key.toString());
ruleFileResource.addResources(key.toString(), talendDrlFiles);
}
} catch (CoreException e) {
ExceptionHandler.process(e);
} catch (MalformedURLException e) {
ExceptionHandler.process(e);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
return list;
}
use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getLibPath.
public List<File> getLibPath(boolean isSpecialMR) {
List<File> ret = new ArrayList<File>();
if (exportFileResource != null) {
ExportFileResource libResource = getCompiledLibExportFileResource(exportFileResource, isSpecialMR);
Collection<Set<URL>> col = libResource.getAllResources();
// this from org.talend.libraries.apache.storm/lib
URL stormLibUrl = null;
File file = null;
try {
stormLibUrl = FileLocator.toFileURL(FileLocator.find(Platform.getBundle(PLUGIN_ID), new Path("lib"), null));
file = new File(stormLibUrl.getFile());
} catch (IOException e) {
ExceptionHandler.process(e);
}
for (Set<URL> set : col) {
Iterator<URL> it = set.iterator();
while (it.hasNext()) {
URL url = it.next();
// for storm not include the jar from libraries.apache.strom
if (!isSpecialMR && stormLibUrl != null && file != null) {
File[] jars = file.listFiles();
String name = url.getFile().substring(url.getFile().lastIndexOf("/") + 1, url.getFile().length());
boolean isExist = false;
for (File jarFile : jars) {
if (jarFile.getName().equals(name)) {
isExist = true;
}
}
if (!isExist) {
ret.add(new File(url.getFile()));
}
} else {
ret.add(new File(url.getFile()));
}
}
}
}
return ret;
}
use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class JobJavaScriptsWSManager method getServerConfigFile.
private ExportFileResource getServerConfigFile(Boolean needConfigFile) {
//$NON-NLS-1$
ExportFileResource webInfo = new ExportFileResource(null, "WEB-INF");
if (!needConfigFile) {
return webInfo;
}
//$NON-NLS-1$
String serverConfigFile = getTmpFolder() + PATH_SEPARATOR + "server-config.wsdd";
List<URL> urlList = new ArrayList<URL>();
try {
urlList.add(new File(serverConfigFile).toURL());
} catch (MalformedURLException e) {
ExceptionHandler.process(e);
}
webInfo.addResources(urlList);
return webInfo;
}
Aggregations