@Transactional public class DefaultAppRegistryService extends Object implements AppRegistryService
AppRegistryService
that operates on higher level
DefaultAppRegistryService
objects and supports on-demand loading of
Resource
s.
Stores AppRegistration with up to two keys:
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 and Description |
---|
DefaultAppRegistryService(AppRegistrationRepository appRegistrationRepository,
AppResourceCommon appResourceCommon,
org.springframework.cloud.dataflow.audit.service.AuditRecordService auditRecordService) |
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) |
public static final String METADATA_KEY_SUFFIX
protected static final org.slf4j.Logger logger
protected final org.springframework.cloud.dataflow.audit.service.AuditRecordService auditRecordService
protected final org.springframework.cloud.dataflow.audit.service.AuditServiceUtils auditServiceUtils
public DefaultAppRegistryService(AppRegistrationRepository appRegistrationRepository, AppResourceCommon appResourceCommon, org.springframework.cloud.dataflow.audit.service.AuditRecordService auditRecordService)
public AppRegistration find(String name, ApplicationType type)
find
in interface AppRegistryService
name
- application nametype
- application typpublic AppRegistration find(String name, ApplicationType type, String version)
find
in interface AppRegistryService
name
- application nametype
- application typeversion
- application versionpublic AppRegistration getDefaultApp(String name, ApplicationType type)
getDefaultApp
in interface AppRegistryService
name
- application nametype
- application versionpublic void validate(AppRegistration registration, String uri, String version)
AppRegistryService
validate
in interface AppRegistryService
registration
- app registrationuri
- uri of the registrationversion
- version of the registrationpublic void setDefaultApp(String name, ApplicationType type, String version)
AppRegistryService
setDefaultApp
in interface AppRegistryService
name
- application nametype
- application typeversion
- application version.public List<AppRegistration> findAll()
findAll
in interface AppRegistryService
AppRegistration
's including multiple version for the same
application.public org.springframework.data.domain.Page<AppRegistration> findAllByTypeAndNameIsLike(ApplicationType type, String name, org.springframework.data.domain.Pageable pageable)
findAllByTypeAndNameIsLike
in interface AppRegistryService
type
- appliation typename
- application namepageable
- Pagination informationAppRegistration
versions for given name and type. Uses the
pagination.public org.springframework.data.domain.Page<AppRegistration> findAllByTypeAndNameIsLikeAndDefaultVersionIsTrue(ApplicationType type, String name, org.springframework.data.domain.Pageable pageable)
findAllByTypeAndNameIsLikeAndDefaultVersionIsTrue
in interface AppRegistryService
type
- appliation typename
- application namepageable
- Pagination informationAppRegistration
s that have the default version set to `true` and matches the given name and type. Uses the
pagination.public org.springframework.data.domain.Page<AppRegistration> findAll(org.springframework.data.domain.Pageable pageable)
findAll
in interface AppRegistryService
pageable
- Pagination informationAppRegistration
's including multiple version for the same
application. Uses the pagination.public AppRegistration save(String name, ApplicationType type, String version, URI uri, URI metadataUri)
AppRegistryService
AppRegistration
identified by its name, type, version and URIs.save
in interface AppRegistryService
name
- Name of the AppRegistration to savetype
- Type of the AppRegistration to saveversion
- Version of the AppRegistration to saveuri
- Resource uri of the AppRegistration to savemetadataUri
- metadata of the AppRegistration to savepublic AppRegistration save(AppRegistration app)
AppRegistryService
AppRegistration
instance.save
in interface AppRegistryService
app
- appRegistration to savepublic void delete(String name, ApplicationType type, String version)
AppRegistration
. If the AppRegistration
does not exist, a
NoSuchAppRegistrationException
will be thrown.delete
in interface AppRegistryService
name
- Name of the AppRegistration to deletetype
- Type of the AppRegistration to deleteversion
- Version of the AppRegistration to deletepublic void deleteAll(Iterable<AppRegistration> appRegistrations)
AppRegistryService
AppRegistration
's.deleteAll
in interface AppRegistryService
appRegistrations
- the AppRegistration
s that will be deletedprotected boolean isOverwrite(AppRegistration app, boolean overwrite)
public boolean appExist(String name, ApplicationType type)
AppRegistryService
appExist
in interface AppRegistryService
name
- applicaiton nametype
- applicaiton typepublic boolean appExist(String name, ApplicationType type, String version)
AppRegistryService
AppRegistration
with this name, type and version exists.appExist
in interface AppRegistryService
name
- application nametype
- application typeversion
- application version.public org.springframework.core.io.Resource getAppResource(AppRegistration appRegistration)
AppRegistryService
getAppResource
in interface AppRegistryService
appRegistration
- the application registrationResource
instance that corresponds to application's URIpublic org.springframework.core.io.Resource getAppMetadataResource(AppRegistration appRegistration)
AppRegistryService
getAppMetadataResource
in interface AppRegistryService
appRegistration
- the application registrationResource
instance that corresponds to application's metdata URIpublic String getResourceVersion(org.springframework.core.io.Resource resource)
getResourceVersion
in interface AppRegistryService
resource
- to retrieve the version forpublic String getResourceWithoutVersion(org.springframework.core.io.Resource resource)
AppRegistryService
getResourceWithoutVersion
in interface AppRegistryService
resource
- to be represented as string.public String getResourceVersion(String uriString)
getResourceVersion
in interface AppRegistryService
uriString
- String representation of the resource URIpublic org.springframework.data.domain.Page<AppRegistration> findAllByTypeAndNameIsLikeAndVersionAndDefaultVersion(ApplicationType type, String name, String version, boolean defaultVersion, org.springframework.data.domain.Pageable pageable)
AppRegistryService
findAllByTypeAndNameIsLikeAndVersionAndDefaultVersion
in interface AppRegistryService
type
- application typename
- application nameversion
- application versiondefaultVersion
- application default versionpageable
- Pagination informationAppRegistration
versions for given name and type. Uses the
pagination.protected Properties loadProperties(org.springframework.core.io.Resource resource)
public List<AppRegistration> importAll(boolean overwrite, org.springframework.core.io.Resource... resources)
AppRegistryService
importAll
in interface AppRegistryService
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 filesCopyright © 2022 Pivotal Software, Inc.. All rights reserved.