Class Application

    • Constructor Detail

      • Application

        protected Application()
    • Method Detail

      • getSdkDocsDir

        public static File getSdkDocsDir()
      • getSdkVersion

        public static com.google.appengine.tools.info.Version getSdkVersion()
      • readApplication

        public static Application readApplication​(String path)
                                           throws 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:
        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​(String path,
                                                  com.google.appengine.tools.admin.RepoInfo.SourceContext sourceContext)
                                           throws 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:
        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​(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:
        IllegalArgumentException - If path does not refer to an existing directory.
      • readApplication

        public static Application readApplication​(String path,
                                                  String appId,
                                                  String module,
                                                  String appVersion)
                                           throws 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:
        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 String getAppId()
        Returns the application identifier, from the AppEngineWebXml config
        Specified by:
        getAppId in interface GenericApplication
        Returns:
        application identifier
      • getVersion

        public String getVersion()
        Returns the application version, from the AppEngineWebXml config
        Specified by:
        getVersion in interface GenericApplication
        Returns:
        application version
      • guessContentTypeFromName

        public static String guessContentTypeFromName​(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 com.google.apphosting.utils.config.AppEngineWebXml getAppEngineWebXml()
        Returns the AppEngineWebXml describing the application.
        Returns:
        a not null deployment descriptor
      • getScrubbedAppEngineWebXml

        public com.google.apphosting.utils.config.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 com.google.apphosting.utils.config.CronXml getCronXml()
        Returns the CronXml describing the applications' cron jobs.
        Specified by:
        getCronXml in interface GenericApplication
        Returns:
        a cron descriptor, possibly empty or null
      • getQueueXml

        public com.google.apphosting.utils.config.QueueXml getQueueXml()
        Returns the QueueXml describing the applications' task queues.
        Specified by:
        getQueueXml in interface GenericApplication
        Returns:
        a queue descriptor, possibly empty or null
      • getDispatchXml

        public com.google.apphosting.utils.config.DispatchXml getDispatchXml()
        Description copied from interface: GenericApplication
        Returns the possibly empty DispatchXml descriptor for this application or null if none is configured.
        Specified by:
        getDispatchXml in interface GenericApplication
      • getDosXml

        public com.google.apphosting.utils.config.DosXml getDosXml()
        Returns the DosXml describing the applications' DoS entries.
        Specified by:
        getDosXml in interface GenericApplication
        Returns:
        a dos descriptor, possibly empty or null
      • getIndexesXml

        public com.google.apphosting.utils.config.IndexesXml getIndexesXml()
        Returns the IndexesXml describing the applications' indexes.
        Specified by:
        getIndexesXml in interface GenericApplication
        Returns:
        a index descriptor, possibly empty or null
      • getWebXml

        public com.google.apphosting.utils.config.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 com.google.apphosting.utils.config.BackendsXml getBackendsXml()
        Description copied from interface: GenericApplication
        Returns the BackendsXml describing the applications' backends.
        Specified by:
        getBackendsXml in interface GenericApplication
        Returns:
        a backends descriptor, possibly empty or null
      • getPath

        public String getPath()
        Returns a path to an exploded WAR directory for the application. This may be a temporary directory.
        Specified by:
        getPath in interface GenericApplication
        Returns:
        a not null path pointing to a directory
      • getStagingOptions

        public com.google.apphosting.utils.config.StagingOptions getStagingOptions​(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 File createStagingDirectory​(ApplicationProcessingOptions opts,
                                           File stagingDir)
                                    throws IOException
        Populates and creates (if necessary) a user specified, staging directory
        Specified by:
        createStagingDirectory in interface 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:
        IOException - if an error occurs trying to create or populate the staging directory
      • exportRepoInfoFile

        public void exportRepoInfoFile()
        Description copied from interface: 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 GenericApplication
      • recursiveDelete

        public static void recursiveDelete​(File dead)
        Recursive directory deletion.