Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix connector deployment issue in synapse-libs #3069

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading