Search in sources :

Example 1 with AppEngineAuthData

use of com.intellij.appengine.cloud.AppEngineAuthData 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);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) WriteCommandAction(com.intellij.openapi.command.WriteCommandAction) PackagingElementResolvingContext(com.intellij.packaging.elements.PackagingElementResolvingContext) Document(com.intellij.openapi.editor.Document) AppEngineWebApp(com.intellij.appengine.descriptor.dom.AppEngineWebApp) Result(com.intellij.openapi.application.Result) AppEngineFacet(com.intellij.appengine.facet.AppEngineFacet) PsiFile(com.intellij.psi.PsiFile) AppEngineSdk(com.intellij.appengine.sdk.AppEngineSdk) AppEngineAuthData(com.intellij.appengine.cloud.AppEngineAuthData) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

AppEngineAuthData (com.intellij.appengine.cloud.AppEngineAuthData)1 AppEngineWebApp (com.intellij.appengine.descriptor.dom.AppEngineWebApp)1 AppEngineFacet (com.intellij.appengine.facet.AppEngineFacet)1 AppEngineSdk (com.intellij.appengine.sdk.AppEngineSdk)1 Result (com.intellij.openapi.application.Result)1 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)1 Document (com.intellij.openapi.editor.Document)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PackagingElementResolvingContext (com.intellij.packaging.elements.PackagingElementResolvingContext)1 PsiFile (com.intellij.psi.PsiFile)1 Nullable (org.jetbrains.annotations.Nullable)1