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;
}
use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class JobExportAction method getProcesses.
private static List<ExportFileResource> getProcesses(Collection<? extends IRepositoryNode> nodes, String path) {
List<ExportFileResource> value = new ArrayList<ExportFileResource>();
for (IRepositoryNode node : nodes) {
if (node.getType() == ENodeType.SYSTEM_FOLDER || node.getType() == ENodeType.SIMPLE_FOLDER) {
value.addAll(getProcesses(node.getChildren(), node.getProperties(EProperties.LABEL).toString() + '/'));
}
if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
IRepositoryViewObject repositoryObject = node.getObject();
if (repositoryObject.getProperty().getItem() instanceof ProcessItem) {
ProcessItem processItem = (ProcessItem) repositoryObject.getProperty().getItem();
ExportFileResource resource = new ExportFileResource(processItem, path + processItem.getProperty().getLabel());
resource.setNode(node);
value.add(resource);
}
}
}
return value;
}
use of org.talend.repository.documentation.ExportFileResource in project tdi-studio-se by Talend.
the class JobExportAction method generatedCodes.
/**
* DOC ggu Comment method "generatedCodes".
*
* @param version
* @param monitor
* @param processes
*/
protected boolean generatedCodes(String version, IProgressMonitor monitor, List<ExportFileResource> processes) {
String projectName = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLabel();
List<JobResource> jobResources = new ArrayList<JobResource>();
for (ExportFileResource process : processes) {
ProcessItem processItem = (ProcessItem) process.getItem();
JobInfo jobInfo = new JobInfo(processItem, processItem.getProcess().getDefaultContext(), version);
jobResources.add(new JobResource(projectName, jobInfo));
Set<JobInfo> jobInfos = ProcessorUtilities.getChildrenJobInfo(processItem);
for (JobInfo subjobInfo : jobInfos) {
jobResources.add(new JobResource(projectName, subjobInfo));
}
}
JobResourceManager reManager = JobResourceManager.getInstance();
for (JobResource r : jobResources) {
if (reManager.isProtected(r)) {
try {
ProcessorUtilities.generateCode(r.getJobInfo().getJobId(), r.getJobInfo().getContextName(), r.getJobInfo().getJobVersion(), false, false, monitor);
} catch (ProcessorException e) {
MessageBoxExceptionHandler.process(e);
return false;
}
}
}
return true;
}
Aggregations