use of org.talend.core.nexus.NexusServerBean in project tesb-studio-se by Talend.
the class CamelTalendEditor method doSave.
@Override
public void doSave(IProgressMonitor monitor) {
super.doSave(monitor);
if (!PluginChecker.isTIS()) {
return;
}
NexusServerBean nexusServerBean = TalendLibsServerManager.getInstance().getCustomNexusServer();
if (nexusServerBean == null) {
return;
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(ILibrariesService.class)) {
ILibrariesService service = (ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class);
List<? extends INode> graphicalNodes = this.getProcess().getGraphicalNodes();
for (INode node : graphicalNodes) {
if (node.getComponent().getName().equals("cConfig")) {
List<Map<String, String>> jars = (List) node.getElementParameter("DRIVER_JAR").getValue();
for (Map<String, String> o : jars) {
String jn = TalendQuoteUtils.removeQuotes(o.get("JAR_NAME"));
String jnv = TalendQuoteUtils.removeQuotes(o.get("JAR_NEXUS_VERSION"));
String jv = String.valueOf(o.get("JAR_PATH"));
String a = jn.replaceFirst("[.][^.]+$", "");
if (StringUtils.isNotBlank(jv)) {
File jarFile = new File(jv);
if (jarFile.exists()) {
try {
service.deployLibrary(jarFile.toURI().toURL(), "mvn:org.talend.libraries/" + a + "/" + jnv + "/jar");
} catch (Exception e) {
e.printStackTrace();
}
cConfigStoredInfo.put(jn, jnv);
o.put("JAR_PATH", "");
}
}
if (cConfigStoredInfo.get(jn) == null) {
cConfigStoredInfo.put(jn, jnv);
continue;
}
if (cConfigStoredInfo.get(jn).equals(jnv)) {
continue;
} else {
MavenArtifact ma = new MavenArtifact();
ma.setArtifactId(a);
ma.setGroupId("org.talend.libraries");
ma.setVersion(cConfigStoredInfo.get(jn));
ma.setType("jar");
String p = PomUtil.getAbsArtifactPath(ma);
if (p != null) {
File file = new File(p);
try {
if (file.exists()) {
File tmp = new File(ExportJobUtil.getTmpFolder() + File.separator + jn);
FilesUtils.copyFile(file, tmp);
service.deployLibrary(tmp.toURI().toURL(), "mvn:org.talend.libraries/" + a + "/" + jnv + "/jar");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}
}
}
Aggregations