public Map<String, Object> convertAppRegistrationToAuditData(AppRegistration appRegistration) { final Map<String, Object> auditData = new HashMap<>(4); auditData.put(APP_NAME, appRegistration.getName()); auditData.put(APP_TYPE, appRegistration.getType()); auditData.put(APP_VERSION, appRegistration.getVersion()); auditData.put(APP_IS_DEFAULT, appRegistration.isDefaultVersion()); auditData.put(APP_URI, appRegistration.getUri()); auditData.put(APP_META_DATA_URI, appRegistration.getMetadataUri()); return auditData; }
@Deprecated @RequestMapping(value = "/{type}/{name}", method = RequestMethod.GET) @ResponseStatus(HttpStatus.OK) public DetailedAppRegistrationResource info( @PathVariable("type") ApplicationType type, @PathVariable("name") String name, @RequestParam(required = false, name = "exhaustive") boolean exhaustive) { if (!this.appRegistryService.appExist(name, type)) { throw new NoSuchAppRegistrationException(name, type); } String defaultVersion = this.appRegistryService.getDefaultApp(name, type).getVersion(); return getInfo(type, name, defaultVersion, exhaustive); }
@Deprecated @RequestMapping(value = "/{type}/{name}", method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) public void unregister(@PathVariable("type") ApplicationType type, @PathVariable("name") String name) { if (this.appRegistryService.find(name, type) == null) { throw new NoSuchAppRegistrationException(name, type); } AppRegistration appRegistration = this.appRegistryService.getDefaultApp(name, type); if (appRegistration == null) { throw new RuntimeException(String.format("No default version exists for the app [%s:%s]", name, type)); } this.unregister(type, name, appRegistration.getVersion()); }
@Override public int compareTo(AppRegistration that) { int i = this.getType().compareTo(that.getType()); if (i == 0) { i = this.getName().compareTo(that.getName()); } if (i == 0) { i = this.getVersion().compareTo(that.getVersion()); } return i; } }
public Map<String, Object> convertAppRegistrationToAuditData(AppRegistration appRegistration) { final Map<String, Object> auditData = new HashMap<>(4); auditData.put(APP_NAME, appRegistration.getName()); auditData.put(APP_TYPE, appRegistration.getType()); auditData.put(APP_VERSION, appRegistration.getVersion()); auditData.put(APP_IS_DEFAULT, appRegistration.isDefaultVersion()); auditData.put(APP_URI, appRegistration.getUri()); auditData.put(APP_META_DATA_URI, appRegistration.getMetadataUri()); return auditData; }
@Override public AppRegistrationResource toResource(AppRegistration registration) { return createResourceWithId(String.format("%s/%s/%s", registration.getType(), registration.getName(), registration.getVersion()), registration); }
@RequestMapping(method = RequestMethod.DELETE) @ResponseStatus(HttpStatus.OK) public void unregisterAll() { List<AppRegistration> appRegistrations = appRegistryService.findAll(); List<AppRegistration> appRegistrationsToUnregister = new ArrayList<>(); for (AppRegistration appRegistration : appRegistrations) { String applicationName = appRegistration.getName(); String applicationVersion = appRegistration.getVersion(); ApplicationType applicationType = appRegistration.getType(); if (applicationType != ApplicationType.task) { String streamWithApp = findStreamContainingAppOf(applicationType, applicationName, applicationVersion); if (streamWithApp == null) { appRegistrationsToUnregister.add(appRegistration); } } else { appRegistrationsToUnregister.add(appRegistration); } } if (!appRegistrationsToUnregister.isEmpty()) { appRegistryService.deleteAll(appRegistrationsToUnregister); } }
protected boolean isOverwrite(AppRegistration app, boolean overwrite) { return overwrite || this.appRegistrationRepository.findAppRegistrationByNameAndTypeAndVersion(app.getName(), app.getType(), app.getVersion()) == null; }
@Override public String toString() { return "AppRegistration{" + "name='" + this.getName() + '\'' + ", type='" + this.getType() + '\'' + ", version='" + this.getVersion() + '\'' + ", uri=" + this.getUri() + ", metadataUri=" + this.getMetadataUri() + '}'; }
@Override protected AppRegistrationResource instantiateResource(AppRegistration registration) { return new AppRegistrationResource(registration.getName(), registration.getType().name(), registration.getVersion(), registration.getUri().toString(), registration.isDefaultVersion()); } }
@Override public AppRegistration save(AppRegistration app) { AppRegistration createdApp; AppRegistration appRegistration = this.appRegistrationRepository.findAppRegistrationByNameAndTypeAndVersion( app.getName(), app.getType(), app.getVersion()); if (appRegistration != null) { appRegistration.setUri(app.getUri()); appRegistration.setMetadataUri(app.getMetadataUri()); createdApp = this.appRegistrationRepository.save(appRegistration); populateAuditData(AuditActionType.UPDATE, createdApp); } else { if (getDefaultApp(app.getName(), app.getType()) == null) { app.setDefaultVersion(true); } createdApp = this.appRegistrationRepository.save(app); populateAuditData(AuditActionType.CREATE, createdApp); } return createdApp; }