Skip to content

Commit

Permalink
Merge pull request #3069 from rosensilva/syanpse_libs_fix
Browse files Browse the repository at this point in the history
Fix connector deployment issue in synapse-libs
  • Loading branch information
arunans23 authored Jun 28, 2024
2 parents 5d49f16 + 78a00e9 commit 985f370
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,10 @@ public boolean accept(File dir, String name) {
log.error("Error while extracting Connector zip : " + connectorZip.getAbsolutePath(), e);
continue;
}
String packageName = retrievePackageName(connectorExtractedPath);

// Retrieve connector name
String connectorName = connectorZip.getName().substring(0, connectorZip.getName().lastIndexOf('-'));
QName qualifiedName = new QName(packageName, connectorName);
QName qualifiedName = retrieveQualifiedConnectorName(connectorExtractedPath);
if (qualifiedName == null) {
continue;
}
File importFile = new File(importsDir, qualifiedName.toString() + ".xml");

if (!importFile.exists()) {
Expand Down Expand Up @@ -155,8 +154,7 @@ private static void generateImportConfig (QName qualifiedName, File targetImport
}


private static String retrievePackageName(String extractedPath) {
String packageName = null;
private static QName retrieveQualifiedConnectorName(String extractedPath) {
File connectorXml = new File(extractedPath + CONNECTOR_XML);
if (!connectorXml.exists()) {
log.error("connector.xml file not found at : " + extractedPath);
Expand All @@ -165,8 +163,11 @@ private static String retrievePackageName(String extractedPath) {
try (InputStream xmlInputStream = new FileInputStream(connectorXml)) {
OMElement connectorDef = new StAXOMBuilder(xmlInputStream).getDocumentElement();
OMAttribute packageAttr = connectorDef.getFirstElement().getAttribute(new QName("package"));
if (packageAttr != null) {
packageName = packageAttr.getAttributeValue();
OMAttribute nameAttr = connectorDef.getFirstElement().getAttribute(new QName("name"));
if (nameAttr != null && packageAttr != null) {
String connectorName = nameAttr.getAttributeValue();
String packageName = packageAttr.getAttributeValue();
return new QName(packageName, connectorName);
}
} catch (XMLStreamException e) {
log.error("Error while parsing the connector.xml file ", e);
Expand All @@ -175,7 +176,7 @@ private static String retrievePackageName(String extractedPath) {
} catch (IOException e) {
log.error("Error occurred while reading: " + connectorXml.getPath());
}
return packageName;
return null;
}


Expand Down

0 comments on commit 985f370

Please sign in to comment.