use of com.intellij.appengine.descriptor.dom.AppEngineWebApp in project intellij-community by JetBrains.
the class AppEngineUploader method createUploader.
@Nullable
public static AppEngineUploader createUploader(@NotNull Project project, @NotNull Artifact artifact, @NotNull AppEngineServerConfiguration configuration, @NotNull ServerRuntimeInstance.DeploymentOperationCallback callback, @NotNull LoggingHandler loggingHandler) {
final String explodedPath = artifact.getOutputPath();
if (explodedPath == null) {
callback.errorOccurred("Output path isn't specified for '" + artifact.getName() + "' artifact");
return null;
}
final AppEngineFacet appEngineFacet = AppEngineUtil.findAppEngineFacet(project, artifact);
if (appEngineFacet == null) {
callback.errorOccurred("App Engine facet not found in '" + artifact.getName() + "' artifact");
return null;
}
final AppEngineSdk sdk = appEngineFacet.getSdk();
if (!sdk.getAppCfgFile().exists()) {
callback.errorOccurred("Path to App Engine SDK isn't specified correctly in App Engine Facet settings");
return null;
}
PackagingElementResolvingContext context = ArtifactManager.getInstance(project).getResolvingContext();
VirtualFile descriptorFile = ArtifactUtil.findSourceFileByOutputPath(artifact, "WEB-INF/appengine-web.xml", context);
final AppEngineWebApp root = AppEngineFacet.getDescriptorRoot(descriptorFile, appEngineFacet.getModule().getProject());
if (root != null) {
final GenericDomValue<String> application = root.getApplication();
if (StringUtil.isEmptyOrSpaces(application.getValue())) {
final String name = Messages.showInputDialog(project, "<html>Application name is not specified in appengine-web.xml.<br>" + "Enter application name (see your <a href=\"http://appengine.google.com\">AppEngine account</a>):</html>", CommonBundle.getErrorTitle(), null, "", null);
if (name == null)
return null;
final PsiFile file = application.getXmlTag().getContainingFile();
new WriteCommandAction(project, file) {
protected void run(@NotNull final Result result) {
application.setStringValue(name);
}
}.execute();
final Document document = PsiDocumentManager.getInstance(project).getDocument(file);
if (document != null) {
FileDocumentManager.getInstance().saveDocument(document);
}
}
}
AppEngineAuthData authData = AppEngineAccountDialog.createAuthData(project, configuration);
if (authData == null)
return null;
return new AppEngineUploader(project, artifact, appEngineFacet, sdk, authData, callback, loggingHandler);
}
Aggregations