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 Resources.

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, Corneil du Plessis
  • Field Details

    • 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 Details

    • DefaultAppRegistryService

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

    • 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 AppRegistrations 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 AppRegistrations 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 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 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(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(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(Resource resource)
    • warnOnMalformedURI

      protected URI warnOnMalformedURI(String key, URI uri)
    • importAll

      public List<AppRegistration> importAll(boolean overwrite, 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