Skip to content
Merged
Show file tree
Hide file tree
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 @@ -477,4 +477,8 @@ export class ExtendedLanguageClient extends LanguageClient {
async getInputOutputMappings(req: GenerateMappingsParamsRequest): Promise<string[]> {
return this.sendRequest('synapse/getInputOutputMappings', req);
}

async isDuplicateConnector(params: string): Promise<any> {
return this.sendRequest("synapse/isDuplicateConnector", { connectorPath: params });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3757,6 +3757,40 @@ ${endpointAttributes}
async copyConnectorZip(params: CopyConnectorZipRequest): Promise<CopyConnectorZipResponse> {
const { connectorPath } = params;
try {
const langClient = await MILanguageClient.getInstance(this.projectUri);
const isDuplicate = await langClient.isDuplicateConnector(connectorPath);
if (isDuplicate?.isFromProject === false) {
window.showErrorMessage('The connector you are trying to add is already added from a dependency project.');
return { success: false };
}
if (isDuplicate?.connectorName) {
const overwrite = await window.showWarningMessage(
`A connector with the name already exists. Do you want to overwrite it?`,
{ modal: true },
'Yes'
);
if (overwrite === 'Yes') {
const rpcClient = new MiVisualizerRpcManager(this.projectUri);
if (isDuplicate?.connectorPath) {
await this.removeConnector({ connectorPath: isDuplicate.connectorPath });
} else {
const projectDetails = await rpcClient.getProjectDetails();
const connectorDependencies = projectDetails.dependencies.connectorDependencies;
for (const dependencies of connectorDependencies) {
if (dependencies.artifact === isDuplicate.artifactId && dependencies.version === isDuplicate.version) {
await rpcClient.updatePomValues({
pomValues: [{ range: dependencies.range, value: '' }]
});
break;
}
}
}
await rpcClient.updateConnectorDependencies();
} else {
return { success: false };
}
}

const connectorDirectory = path.join(this.projectUri, 'src', 'main', 'wso2mi', 'resources', 'connectors');

if (!fs.existsSync(connectorDirectory)) {
Expand Down
Loading