Skip to content

Commit 50df2ec

Browse files
author
Summer
authored
Revert to use FTP to upload jar artifact (#2052)
1 parent 4318d31 commit 50df2ec

File tree

1 file changed

+27
-1
lines changed
  • PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/webapp/webappconfig

1 file changed

+27
-1
lines changed

PluginsAndFeatures/azure-toolkit-for-intellij/src/com/microsoft/intellij/runner/webapp/webappconfig/WebAppRunState.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public class WebAppRunState extends AzureRunProfileState<WebApp> {
7373

7474
private static final String WEB_CONFIG_PACKAGE_PATH = "/webapp/web.config";
7575
private static final String BASE_PATH = "/site/wwwroot/";
76+
private static final String ROOT_PATH = BASE_PATH + "app.jar";
77+
private static final String WEB_CONFIG_FTP_PATH = "/site/wwwroot/web.config";
7678
private static final String WEB_APP_BASE_PATH = BASE_PATH + "webapps/";
7779
private static final String CONTAINER_ROOT_PATH = WEB_APP_BASE_PATH + "ROOT";
7880
private static final String TEMP_FILE_PREFIX = "azuretoolkit";
@@ -113,7 +115,9 @@ public WebApp executeSteps(@NotNull RunProcessHandler processHandler
113115
}
114116
break;
115117
case MavenConstants.TYPE_JAR:
116-
uploadJarArtifact(webAppSettingModel.getTargetPath(), webApp, processHandler, telemetryMap);
118+
try (FileInputStream input = new FileInputStream(webAppSettingModel.getTargetPath())) {
119+
uploadJarArtifactViaFTP(input, webApp, processHandler, telemetryMap);
120+
}
117121
break;
118122
default:
119123
break;
@@ -264,6 +268,28 @@ private void uploadJarArtifact(@NotNull String fileName, @NotNull WebApp webApp,
264268
telemetryMap.put("artifactUploadCount", String.valueOf(uploadCount));
265269
}
266270

271+
private void uploadJarArtifactViaFTP(@NotNull final FileInputStream input, @NotNull WebApp webApp,
272+
@NotNull RunProcessHandler processHandler,
273+
@NotNull Map<String, String> telemetryMap) throws Exception {
274+
processHandler.setText(GETTING_DEPLOYMENT_CREDENTIAL);
275+
PublishingProfile profile = webApp.getPublishingProfile();
276+
277+
processHandler.setText(CONNECTING_FTP);
278+
FTPClient ftp = WebAppUtils.getFtpConnection(profile);
279+
280+
if (webApp.operatingSystem() == OperatingSystem.WINDOWS) {
281+
processHandler.setText(UPLOADING_WEB_CONFIG);
282+
try (InputStream webConfigInput = getClass().getResourceAsStream(WEB_CONFIG_PACKAGE_PATH)) {
283+
int webConfigUploadCount = uploadFileToFtp(ftp, WEB_CONFIG_FTP_PATH, webConfigInput, processHandler);
284+
telemetryMap.put("webConfigCount", String.valueOf(webConfigUploadCount));
285+
}
286+
}
287+
288+
processHandler.setText(String.format(UPLOADING_ARTIFACT, ROOT_PATH));
289+
final int uploadCount = uploadFileToFtp(ftp, ROOT_PATH, input, processHandler);
290+
telemetryMap.put("artifactUploadCount", String.valueOf(uploadCount));
291+
}
292+
267293
// Add retry logic here to avoid Kudu's socket timeout issue.
268294
// For each try, the method will wait 5 seconds.
269295
// More details: https://github.com/Microsoft/azure-maven-plugins/issues/339

0 commit comments

Comments
 (0)