com.google.appengine.tools.admin

## Class Application

- java.lang.Object
- - com.google.appengine.tools.admin.Application

- All Implemented Interfaces:
    com.google.appengine.tools.admin.GenericApplication

      public class Application
      extends java.lang.Object
      implements com.google.appengine.tools.admin.GenericApplication

  An App Engine application. You can `read` an `Application` from a path, and `create` an `AppAdmin` to upload, create indexes, or otherwise manage it.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.google.appengine.tools.admin.GenericApplication

      `com.google.appengine.tools.admin.GenericApplication.ErrorHandler`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cleanStagingDirectory()` deletes the staging directory, if one was created.
    `java.io.File` | `createStagingDirectory(com.google.appengine.tools.admin.ApplicationProcessingOptions opts)` Creates a new staging directory, if needed, or returns the existing one if already created.
    `java.io.File` | `createStagingDirectory(com.google.appengine.tools.admin.ApplicationProcessingOptions opts, java.io.File stagingDir)` Populates and creates (if necessary) a user specified, staging directory
    `void` | `exportRepoInfoFile()` Generates source context file in the staging directory.
    `java.lang.String` | `getApiVersion()` Returns the desired API version for the current application, or `"none"` if no API version was used.
    `AppEngineWebXml` | `getAppEngineWebXml()` Returns the AppEngineWebXml describing the application.
    `java.lang.String` | `getAppId()` Returns the application identifier, from the AppEngineWebXml config
    `java.lang.String` | `getAppYaml()` Returns the app.yaml string.
    `BackendsXml` | `getBackendsXml()` Returns the BackendsXml describing the applications' backends.
    `CronXml` | `getCronXml()` Returns the CronXml describing the applications' cron jobs.
    `DispatchXml` | `getDispatchXml()` Returns the possibly empty `DispatchXml` descriptor for this application or null if none is configured.
    `DosXml` | `getDosXml()` Returns the DosXml describing the applications' DoS entries.
    `java.util.List<com.google.appengine.tools.admin.GenericApplication.ErrorHandler>` | `getErrorHandlers()` Returns the list of error handlers for this application
    `IndexesXml` | `getIndexesXml()` Returns the IndexesXml describing the applications' indexes.
    `java.lang.String` | `getInstanceClass()` Returns the application instance class name or null if not specified.
    `java.lang.String` | `getMimeTypeIfStatic(java.lang.String path)` Returns the mime-type if path corresponds to static content, `null` otherwise.
    `java.lang.String` | `getModule()` Returns the application module name or null if not specified.
    `java.lang.String` | `getPath()` Returns a path to an exploded WAR directory for the application.
    `QueueXml` | `getQueueXml()` Returns the QueueXml describing the applications' task queues.
    `java.lang.String` | `getRuntime()` Returns the desired runtime for the current application.
    `AppEngineWebXml` | `getScrubbedAppEngineWebXml()` Modified app.yaml for Cloud SDK deployment.
    `static java.io.File` | `getSdkDocsDir()`
    `static Version` | `getSdkVersion()`
    `java.io.File` | `getStagingDir()` Returns the staging directory, or `null` if none has been created.
    `StagingOptions` | `getStagingOptions(com.google.appengine.tools.admin.ApplicationProcessingOptions opts)` Gets the effective staging options from global defaults, appengine-web.xml and flags, in ascending order of precedence.
    `java.lang.String` | `getVersion()` Returns the application version, from the AppEngineWebXml config
    `WebXml` | `getWebXml()` Returns the WebXml describing the applications' servlets and generic web application information.
    `static java.lang.String` | `guessContentTypeFromName(java.lang.String fileName)`
    `boolean` | `isPrecompilationEnabled()` Returns whether precompilation is enabled for this application
    `static Application` | `readApplication(java.lang.String path)` Reads the App Engine application from `path`.
    `static Application` | `readApplication(java.lang.String path, com.google.appengine.tools.admin.RepoInfo.SourceContext sourceContext)` Reads the App Engine application from `path`.
    `static Application` | `readApplication(java.lang.String path, java.lang.String appId, java.lang.String module, java.lang.String appVersion)` Reads the App Engine application from `path`.
    `static void` | `recursiveDelete(java.io.File dead)` Recursive directory deletion.
    `void` | `resetProgress()`
    `void` | `setDetailsWriter(java.io.PrintWriter detailsWriter)`
    `void` | `setExternalResourceDir(java.lang.String path)` Sets the external resource directory.
    `void` | `setListener(UpdateListener l)`
    `void` | `statusUpdate(java.lang.String message)`
    `void` | `statusUpdate(java.lang.String message, int amount)`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getSdkDocsDir

          public static java.io.File getSdkDocsDir()

    - #### getSdkVersion

          public static Version getSdkVersion()

    - #### readApplication

          public static Application readApplication(java.lang.String path)
                                             throws java.io.IOException

      Reads the App Engine application from `path`. The path may either be a WAR file or the root of an exploded WAR directory.
      Parameters:
        `path` - a not `null` path.
      Throws:
        `java.io.IOException` - if an error occurs while trying to read the `Application`.
        `com.google.apphosting.utils.config.AppEngineConfigException` - if the `Application's` appengine-web.xml file is malformed.

    - #### readApplication

          public static Application readApplication(java.lang.String path,
                                                    com.google.appengine.tools.admin.RepoInfo.SourceContext sourceContext)
                                             throws java.io.IOException

      Reads the App Engine application from `path`. The path may either be a WAR file or the root of an exploded WAR directory.
      Parameters:
        `path` - a not `null` path.
        `sourceContext` - an explicit RepoInfo.SourceContext. If `null`, the source context will be inferred from the current directory.
      Throws:
        `java.io.IOException` - if an error occurs while trying to read the `Application`.
        `com.google.apphosting.utils.config.AppEngineConfigException` - if the `Application's` appengine-web.xml file is malformed.

    - #### setExternalResourceDir

          public void setExternalResourceDir(java.lang.String path)

      Sets the external resource directory. Call this method before invoking `createStagingDirectory(ApplicationProcessingOptions)`.

      The external resource directory is a directory outside of the war directory where additional files live. These files will be copied into the staging directory during an upload, after the war directory is copied there. Consequently if there are any name collisions the files in the external resource directory will win.

      Parameters:
        `path` - a not `null` path to an existing directory.
      Throws:
        `java.lang.IllegalArgumentException` - If `path` does not refer to an existing directory.

    - #### readApplication

          public static Application readApplication(java.lang.String path,
                                                    java.lang.String appId,
                                                    java.lang.String module,
                                                    java.lang.String appVersion)
                                             throws java.io.IOException

      Reads the App Engine application from `path`. The path may either be a WAR file or the root of an exploded WAR directory.
      Parameters:
        `path` - a not `null` path.
        `appId` - if non-null, use this as an application id override.
        `module` - if non-null, use this as a module id override.
        `appVersion` - if non-null, use this as an application version override.
      Throws:
        `java.io.IOException` - if an error occurs while trying to read the `Application`.
        `com.google.apphosting.utils.config.AppEngineConfigException` - if the `Application's` appengine-web.xml file is malformed.

    - #### getAppId

          public java.lang.String getAppId()

      Returns the application identifier, from the AppEngineWebXml config
      Specified by:
        `getAppId` in interface `com.google.appengine.tools.admin.GenericApplication`
      Returns:
        application identifier

    - #### getVersion

          public java.lang.String getVersion()

      Returns the application version, from the AppEngineWebXml config
      Specified by:
        `getVersion` in interface `com.google.appengine.tools.admin.GenericApplication`
      Returns:
        application version

    - #### getModule

          public java.lang.String getModule()

      Description copied from interface: `com.google.appengine.tools.admin.GenericApplication`
      Returns the application module name or null if not specified.
      Specified by:
        `getModule` in interface `com.google.appengine.tools.admin.GenericApplication`

    - #### getInstanceClass

          public java.lang.String getInstanceClass()

      Description copied from interface: `com.google.appengine.tools.admin.GenericApplication`
      Returns the application instance class name or null if not specified.
      Specified by:
        `getInstanceClass` in interface `com.google.appengine.tools.admin.GenericApplication`

    - #### isPrecompilationEnabled

          public boolean isPrecompilationEnabled()

      Description copied from interface: `com.google.appengine.tools.admin.GenericApplication`
      Returns whether precompilation is enabled for this application
      Specified by:
        `isPrecompilationEnabled` in interface `com.google.appengine.tools.admin.GenericApplication`
      Returns:
        precompilation setting

    - #### getErrorHandlers

          public java.util.List<com.google.appengine.tools.admin.GenericApplication.ErrorHandler> getErrorHandlers()

      Description copied from interface: `com.google.appengine.tools.admin.GenericApplication`
      Returns the list of error handlers for this application
      Specified by:
        `getErrorHandlers` in interface `com.google.appengine.tools.admin.GenericApplication`
      Returns:
        error handlers

    - #### getMimeTypeIfStatic

          public java.lang.String getMimeTypeIfStatic(java.lang.String path)

      Description copied from interface: `com.google.appengine.tools.admin.GenericApplication`
      Returns the mime-type if path corresponds to static content, `null` otherwise.
      Specified by:
        `getMimeTypeIfStatic` in interface `com.google.appengine.tools.admin.GenericApplication`
      Returns:
        mime-type, possibly `null`

    - #### guessContentTypeFromName

          public static java.lang.String guessContentTypeFromName(java.lang.String fileName)

      Parameters:
        `fileName` - path of a file with extension
      Returns:
        the mimetype of the file (or application/octect-stream if not recognized)

    - #### getAppEngineWebXml

          public AppEngineWebXml getAppEngineWebXml()

      Returns the AppEngineWebXml describing the application.
      Returns:
        a not `null` deployment descriptor

    - #### getScrubbedAppEngineWebXml

          public AppEngineWebXml getScrubbedAppEngineWebXml()

      Modified app.yaml for Cloud SDK deployment. This method is not called for App Engine Classic deployment, and called only for the "stage" command. Replaces module to service and clears out the application/version params.
      Returns:
        a not `null` deployment descriptor

    - #### getCronXml

          public CronXml getCronXml()

      Returns the CronXml describing the applications' cron jobs.
      Specified by:
        `getCronXml` in interface `com.google.appengine.tools.admin.GenericApplication`
      Returns:
        a cron descriptor, possibly empty or `null`

    - #### getQueueXml

          public QueueXml getQueueXml()

      Returns the QueueXml describing the applications' task queues.
      Specified by:
        `getQueueXml` in interface `com.google.appengine.tools.admin.GenericApplication`
      Returns:
        a queue descriptor, possibly empty or `null`

    - #### getDispatchXml

          public DispatchXml getDispatchXml()

      Description copied from interface: `com.google.appengine.tools.admin.GenericApplication`
      Returns the possibly empty `DispatchXml` descriptor for this application or null if none is configured.
      Specified by:
        `getDispatchXml` in interface `com.google.appengine.tools.admin.GenericApplication`

    - #### getDosXml

          public DosXml getDosXml()

      Returns the DosXml describing the applications' DoS entries.
      Specified by:
        `getDosXml` in interface `com.google.appengine.tools.admin.GenericApplication`
      Returns:
        a dos descriptor, possibly empty or `null`

    - #### getIndexesXml

          public IndexesXml getIndexesXml()

      Returns the IndexesXml describing the applications' indexes.
      Specified by:
        `getIndexesXml` in interface `com.google.appengine.tools.admin.GenericApplication`
      Returns:
        a index descriptor, possibly empty or `null`

    - #### getWebXml

          public WebXml getWebXml()

      Returns the WebXml describing the applications' servlets and generic web application information.
      Returns:
        a WebXml descriptor, possibly empty but not `null`

    - #### getBackendsXml

          public BackendsXml getBackendsXml()

      Description copied from interface: `com.google.appengine.tools.admin.GenericApplication`
      Returns the BackendsXml describing the applications' backends.
      Specified by:
        `getBackendsXml` in interface `com.google.appengine.tools.admin.GenericApplication`
      Returns:
        a backends descriptor, possibly empty or `null`

    - #### getApiVersion

          public java.lang.String getApiVersion()

      Returns the desired API version for the current application, or `"none"` if no API version was used.
      Specified by:
        `getApiVersion` in interface `com.google.appengine.tools.admin.GenericApplication`
      Throws:
        `java.lang.IllegalStateException` - if createStagingDirectory has not been called.

    - #### getRuntime

          public java.lang.String getRuntime()

      Returns the desired runtime for the current application.
      Specified by:
        `getRuntime` in interface `com.google.appengine.tools.admin.GenericApplication`
      Throws:
        `java.lang.IllegalStateException` - if createStagingDirectory has not been called.

    - #### getPath

          public java.lang.String getPath()

      Returns a path to an exploded WAR directory for the application. This may be a temporary directory.
      Specified by:
        `getPath` in interface `com.google.appengine.tools.admin.GenericApplication`
      Returns:
        a not `null` path pointing to a directory

    - #### getStagingDir

          public java.io.File getStagingDir()

      Returns the staging directory, or `null` if none has been created.
      Specified by:
        `getStagingDir` in interface `com.google.appengine.tools.admin.GenericApplication`

    - #### resetProgress

          public void resetProgress()

      Specified by:
        `resetProgress` in interface `com.google.appengine.tools.admin.GenericApplication`

    - #### getStagingOptions

          public StagingOptions getStagingOptions(com.google.appengine.tools.admin.ApplicationProcessingOptions opts)

      Gets the effective staging options from global defaults, appengine-web.xml and flags, in ascending order of precedence. For instance, a flag overrides a value of appengine-web.xml.
      Parameters:
        `opts` - User-specified options for processing the application.
      Returns:
        StagingOptions a complete object respecting the precedence in assignment

    - #### createStagingDirectory

          public java.io.File createStagingDirectory(com.google.appengine.tools.admin.ApplicationProcessingOptions opts)
                                              throws java.io.IOException

      Creates a new staging directory, if needed, or returns the existing one if already created.
      Specified by:
        `createStagingDirectory` in interface `com.google.appengine.tools.admin.GenericApplication`
      Parameters:
        `opts` - User-specified options for processing the application.
      Returns:
        staging directory
      Throws:
        `java.io.IOException`

    - #### createStagingDirectory

          public java.io.File createStagingDirectory(com.google.appengine.tools.admin.ApplicationProcessingOptions opts,
                                                     java.io.File stagingDir)
                                              throws java.io.IOException

      Populates and creates (if necessary) a user specified, staging directory
      Specified by:
        `createStagingDirectory` in interface `com.google.appengine.tools.admin.GenericApplication`
      Parameters:
        `opts` - User-specified options for processing the application.
        `stagingDir` - User-specified staging directory (must be empty or not exist)
      Returns:
        staging directory
      Throws:
        `java.io.IOException` - if an error occurs trying to create or populate the staging directory

    - #### exportRepoInfoFile

          public void exportRepoInfoFile()

      Description copied from interface: `com.google.appengine.tools.admin.GenericApplication`
      Generates source context file in the staging directory.

      Does nothing if the source directory is not in a Git repo or if the source context file already exists. If the operation fails, this function logs and continues. The deployment is never blocked if we can't generate the source context file.

      Specified by:
        `exportRepoInfoFile` in interface `com.google.appengine.tools.admin.GenericApplication`

    - #### cleanStagingDirectory

          public void cleanStagingDirectory()

      deletes the staging directory, if one was created.
      Specified by:
        `cleanStagingDirectory` in interface `com.google.appengine.tools.admin.GenericApplication`

    - #### recursiveDelete

          public static void recursiveDelete(java.io.File dead)

      Recursive directory deletion.

    - #### setListener

          public void setListener(UpdateListener l)

      Specified by:
        `setListener` in interface `com.google.appengine.tools.admin.GenericApplication`

    - #### setDetailsWriter

          public void setDetailsWriter(java.io.PrintWriter detailsWriter)

      Specified by:
        `setDetailsWriter` in interface `com.google.appengine.tools.admin.GenericApplication`

    - #### statusUpdate

          public void statusUpdate(java.lang.String message,
                                   int amount)

      Specified by:
        `statusUpdate` in interface `com.google.appengine.tools.admin.GenericApplication`

    - #### statusUpdate

          public void statusUpdate(java.lang.String message)

      Specified by:
        `statusUpdate` in interface `com.google.appengine.tools.admin.GenericApplication`

    - #### getAppYaml

          public java.lang.String getAppYaml()

      Returns the app.yaml string.
      Specified by:
        `getAppYaml` in interface `com.google.appengine.tools.admin.GenericApplication`
      Returns:
        application configuration yaml string
      Throws:
        `java.lang.IllegalStateException` - if createStagingDirectory has not been called.