org.springframework.cloud.dataflow.registry.service

## Class DefaultAppRegistryService

- java.lang.Object
- - org.springframework.cloud.dataflow.registry.service.DefaultAppRegistryService

- All Implemented Interfaces:
    AppRegistryService

      @Transactional
      public class DefaultAppRegistryService
      extends Object
      implements AppRegistryService

  Convenience wrapper for the `AppRegistryService` that operates on higher level `DefaultAppRegistryService` objects and supports on-demand loading of `Resource`s.

  Stores AppRegistration with up to two keys:

  - <type>.<name>: URI for the actual app
  - <type>.<name>.metadata: Optional URI for the app metadata
  Author:
    Mark Fisher, Gunnar Hillert, Thomas Risberg, Eric Bottard, Ilayaperumal Gopinathan, Oleg Zhurakousky, Christian Tzolov, Chris Schaefer

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.springframework.cloud.dataflow.audit.service.AuditRecordService` | `auditRecordService`
    `protected org.springframework.cloud.dataflow.audit.service.AuditServiceUtils` | `auditServiceUtils`
    `protected static org.slf4j.Logger` | `logger`
    `static String` | `METADATA_KEY_SUFFIX`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultAppRegistryService(AppRegistrationRepository appRegistrationRepository, AppResourceCommon appResourceCommon, org.springframework.cloud.dataflow.audit.service.AuditRecordService auditRecordService)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `appExist(String name, ApplicationType type)` Checks if an application with such name and type exists and is set as default.
    `boolean` | `appExist(String name, ApplicationType type, String version)` Checks if an `AppRegistration` with this name, type and version exists.
    `void` | `delete(String name, ApplicationType type, String version)` Deletes an `AppRegistration`.
    `void` | `deleteAll(Iterable<AppRegistration> appRegistrations)` Deletes all provided `AppRegistration`'s.
    `AppRegistration` | `find(String name, ApplicationType type)`
    `AppRegistration` | `find(String name, ApplicationType type, String version)`
    `List<AppRegistration>` | `findAll()`
    `org.springframework.data.domain.Page<AppRegistration>` | `findAll(org.springframework.data.domain.Pageable pageable)`
    `org.springframework.data.domain.Page<AppRegistration>` | `findAllByTypeAndNameIsLike(ApplicationType type, String name, org.springframework.data.domain.Pageable pageable)`
    `org.springframework.data.domain.Page<AppRegistration>` | `findAllByTypeAndNameIsLikeAndDefaultVersionIsTrue(ApplicationType type, String name, org.springframework.data.domain.Pageable pageable)`
    `org.springframework.data.domain.Page<AppRegistration>` | `findAllByTypeAndNameIsLikeAndVersionAndDefaultVersion(ApplicationType type, String name, String version, boolean defaultVersion, org.springframework.data.domain.Pageable pageable)` Returns all app registrations based on various optional parameters.
    `org.springframework.core.io.Resource` | `getAppMetadataResource(AppRegistration appRegistration)` Converts application's metadata URI into Spring resource object.
    `org.springframework.core.io.Resource` | `getAppResource(AppRegistration appRegistration)` Converts application's URI into Spring resource object.
    `AppRegistration` | `getDefaultApp(String name, ApplicationType type)`
    `String` | `getResourceVersion(org.springframework.core.io.Resource resource)`
    `String` | `getResourceVersion(String uriString)` Returns the version for the given resource URI string.
    `String` | `getResourceWithoutVersion(org.springframework.core.io.Resource resource)` Returns a string representing the resource with version subtracted
    `List<AppRegistration>` | `importAll(boolean overwrite, org.springframework.core.io.Resource... resources)` Import bulk of applications from input load files
    `protected boolean` | `isOverwrite(AppRegistration app, boolean overwrite)`
    `protected Properties` | `loadProperties(org.springframework.core.io.Resource resource)`
    `AppRegistration` | `save(AppRegistration app)` Save an `AppRegistration` instance.
    `AppRegistration` | `save(String name, ApplicationType type, String version, URI uri, URI metadataUri)` Saves a new `AppRegistration` identified by its name, type, version and URIs.
    `void` | `setDefaultApp(String name, ApplicationType type, String version)` Set an application with name, type and version as the default for all name:type applications.
    `void` | `validate(AppRegistration registration, String uri, String version)` Validate given registration with given uri and version.
    `protected URI` | `warnOnMalformedURI(String key, URI uri)`

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

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

- - ### Field Detail

    - #### METADATA_KEY_SUFFIX

          public static final String METADATA_KEY_SUFFIX

      See Also:
        Constant Field Values

    - #### logger

          protected static final org.slf4j.Logger logger

    - #### auditRecordService

          protected final org.springframework.cloud.dataflow.audit.service.AuditRecordService auditRecordService

    - #### auditServiceUtils

          protected final org.springframework.cloud.dataflow.audit.service.AuditServiceUtils auditServiceUtils

  - ### Constructor Detail

    - #### DefaultAppRegistryService

          public DefaultAppRegistryService(AppRegistrationRepository appRegistrationRepository,
                                           AppResourceCommon appResourceCommon,
                                           org.springframework.cloud.dataflow.audit.service.AuditRecordService auditRecordService)

  - ### Method Detail

    - #### find

          public AppRegistration find(String name,
                                      ApplicationType type)

      Specified by:
        `find` in interface `AppRegistryService`
      Parameters:
        `name` - application name
        `type` - application typ
      Returns:
        the application with those name and type and default version

    - #### find

          public AppRegistration find(String name,
                                      ApplicationType type,
                                      String version)

      Specified by:
        `find` in interface `AppRegistryService`
      Parameters:
        `name` - application name
        `type` - application type
        `version` - application version
      Returns:
        the application with those name and type and default version

    - #### getDefaultApp

          public AppRegistration getDefaultApp(String name,
                                               ApplicationType type)

      Specified by:
        `getDefaultApp` in interface `AppRegistryService`
      Parameters:
        `name` - application name
        `type` - application version
      Returns:
        the default application for this name:type pair. Returns null if no name:type application exists or if none of the name:type applications is set as default.

    - #### validate

          public void validate(AppRegistration registration,
                               String uri,
                               String version)

      Description copied from interface: `AppRegistryService`
      Validate given registration with given uri and version. Validation will fail if given uri logically impossible to use with further expected logic with using versions.
      Specified by:
        `validate` in interface `AppRegistryService`
      Parameters:
        `registration` - app registration
        `uri` - uri of the registration
        `version` - version of the registration

    - #### setDefaultApp

          public void setDefaultApp(String name,
                                    ApplicationType type,
                                    String version)

      Description copied from interface: `AppRegistryService`
      Set an application with name, type and version as the default for all name:type applications. The previous default name:type application is set to non-default.
      Specified by:
        `setDefaultApp` in interface `AppRegistryService`
      Parameters:
        `name` - application name
        `type` - application type
        `version` - application version.

    - #### findAll

          public List<AppRegistration> findAll()

      Specified by:
        `findAll` in interface `AppRegistryService`
      Returns:
        returns all `AppRegistration`'s including multiple version for the same application.

    - #### findAllByTypeAndNameIsLike

          public org.springframework.data.domain.Page<AppRegistration> findAllByTypeAndNameIsLike(ApplicationType type,
                                                                                                  String name,
                                                                                                  org.springframework.data.domain.Pageable pageable)

      Specified by:
        `findAllByTypeAndNameIsLike` in interface `AppRegistryService`
      Parameters:
        `type` - appliation type
        `name` - application name
        `pageable` - Pagination information
      Returns:
        returns all `AppRegistration` versions for given name and type. Uses the pagination.

    - #### findAllByTypeAndNameIsLikeAndDefaultVersionIsTrue

          public org.springframework.data.domain.Page<AppRegistration> findAllByTypeAndNameIsLikeAndDefaultVersionIsTrue(ApplicationType type,
                                                                                                                         String name,
                                                                                                                         org.springframework.data.domain.Pageable pageable)

      Specified by:
        `findAllByTypeAndNameIsLikeAndDefaultVersionIsTrue` in interface `AppRegistryService`
      Parameters:
        `type` - appliation type
        `name` - application name
        `pageable` - Pagination information
      Returns:
        returns the `AppRegistration`s that have the default version set to `true` and matches the given name and type. Uses the pagination.

    - #### findAll

          public org.springframework.data.domain.Page<AppRegistration> findAll(org.springframework.data.domain.Pageable pageable)

      Specified by:
        `findAll` in interface `AppRegistryService`
      Parameters:
        `pageable` - Pagination information
      Returns:
        returns all `AppRegistration`'s including multiple version for the same application. Uses the pagination.

    - #### save

          public AppRegistration save(String name,
                                      ApplicationType type,
                                      String version,
                                      URI uri,
                                      URI metadataUri)

      Description copied from interface: `AppRegistryService`
      Saves a new `AppRegistration` identified by its name, type, version and URIs.
      Specified by:
        `save` in interface `AppRegistryService`
      Parameters:
        `name` - Name of the AppRegistration to save
        `type` - Type of the AppRegistration to save
        `version` - Version of the AppRegistration to save
        `uri` - Resource uri of the AppRegistration to save
        `metadataUri` - metadata of the AppRegistration to save
      Returns:
        the saved AppRegistration

    - #### save

          public AppRegistration save(AppRegistration app)

      Description copied from interface: `AppRegistryService`
      Save an `AppRegistration` instance.
      Specified by:
        `save` in interface `AppRegistryService`
      Parameters:
        `app` - appRegistration to save
      Returns:
        the saved appRegistration

    - #### delete

          public void delete(String name,
                             ApplicationType type,
                             String version)

      Deletes an `AppRegistration`. If the `AppRegistration` does not exist, a `NoSuchAppRegistrationException` will be thrown.
      Specified by:
        `delete` in interface `AppRegistryService`
      Parameters:
        `name` - Name of the AppRegistration to delete
        `type` - Type of the AppRegistration to delete
        `version` - Version of the AppRegistration to delete

    - #### deleteAll

          public void deleteAll(Iterable<AppRegistration> appRegistrations)

      Description copied from interface: `AppRegistryService`
      Deletes all provided `AppRegistration`'s.
      Specified by:
        `deleteAll` in interface `AppRegistryService`
      Parameters:
        `appRegistrations` - the `AppRegistration`s that will be deleted

    - #### isOverwrite

          protected boolean isOverwrite(AppRegistration app,
                                        boolean overwrite)

    - #### appExist

          public boolean appExist(String name,
                                  ApplicationType type)

      Description copied from interface: `AppRegistryService`
      Checks if an application with such name and type exists and is set as default.
      Specified by:
        `appExist` in interface `AppRegistryService`
      Parameters:
        `name` - applicaiton name
        `type` - applicaiton type
      Returns:
        true if a default application with this name and type exists.

    - #### appExist

          public boolean appExist(String name,
                                  ApplicationType type,
                                  String version)

      Description copied from interface: `AppRegistryService`
      Checks if an `AppRegistration` with this name, type and version exists.
      Specified by:
        `appExist` in interface `AppRegistryService`
      Parameters:
        `name` - application name
        `type` - application type
        `version` - application version.
      Returns:
        true if the AppRegistration exists, false otherwise.

    - #### getAppResource

          public org.springframework.core.io.Resource getAppResource(AppRegistration appRegistration)

      Description copied from interface: `AppRegistryService`
      Converts application's URI into Spring resource object. Supports File:, Http:, Maven: and Docker: schemas
      Specified by:
        `getAppResource` in interface `AppRegistryService`
      Parameters:
        `appRegistration` - the application registration
      Returns:
        Returns `Resource` instance that corresponds to application's URI

    - #### getAppMetadataResource

          public org.springframework.core.io.Resource getAppMetadataResource(AppRegistration appRegistration)

      Description copied from interface: `AppRegistryService`
      Converts application's metadata URI into Spring resource object. Supports File:, Http:, Maven: and Docker: schemas
      Specified by:
        `getAppMetadataResource` in interface `AppRegistryService`
      Parameters:
        `appRegistration` - the application registration
      Returns:
        Returns `Resource` instance that corresponds to application's metdata URI

    - #### getResourceVersion

          public String getResourceVersion(org.springframework.core.io.Resource resource)

      Specified by:
        `getResourceVersion` in interface `AppRegistryService`
      Parameters:
        `resource` - to retrieve the version for
      Returns:
        Returns the version for the provided resource

    - #### getResourceWithoutVersion

          public String getResourceWithoutVersion(org.springframework.core.io.Resource resource)

      Description copied from interface: `AppRegistryService`
      Returns a string representing the resource with version subtracted
      Specified by:
        `getResourceWithoutVersion` in interface `AppRegistryService`
      Parameters:
        `resource` - to be represented as string.
      Returns:
        String representation of the resource.

    - #### getResourceVersion

          public String getResourceVersion(String uriString)

      Returns the version for the given resource URI string.
      Specified by:
        `getResourceVersion` in interface `AppRegistryService`
      Parameters:
        `uriString` - String representation of the resource URI
      Returns:
        the resource version

    - #### findAllByTypeAndNameIsLikeAndVersionAndDefaultVersion

          public org.springframework.data.domain.Page<AppRegistration> findAllByTypeAndNameIsLikeAndVersionAndDefaultVersion(ApplicationType type,
                                                                                                                             String name,
                                                                                                                             String version,
                                                                                                                             boolean defaultVersion,
                                                                                                                             org.springframework.data.domain.Pageable pageable)

      Description copied from interface: `AppRegistryService`
      Returns all app registrations based on various optional parameters.
      Specified by:
        `findAllByTypeAndNameIsLikeAndVersionAndDefaultVersion` in interface `AppRegistryService`
      Parameters:
        `type` - application type
        `name` - application name
        `version` - application version
        `defaultVersion` - application default version
        `pageable` - Pagination information
      Returns:
        returns all `AppRegistration` versions for given name and type. Uses the pagination.

    - #### loadProperties

          protected Properties loadProperties(org.springframework.core.io.Resource resource)

    - #### warnOnMalformedURI

          protected URI warnOnMalformedURI(String key,
                                           URI uri)

    - #### importAll

          public List<AppRegistration> importAll(boolean overwrite,
                                                 org.springframework.core.io.Resource... resources)

      Description copied from interface: `AppRegistryService`
      Import bulk of applications from input load files
      Specified by:
        `importAll` in interface `AppRegistryService`
      Parameters:
        `overwrite` - if set to true this command will override and existing application with same name:type:version If set to false operation will throw an exception in the application already exists.
        `resources` - list of input load files
      Returns:
        list of application being imported

Copyright © 2021 Pivotal Software, Inc.. All rights reserved.