@Override public AppRegistryCommands.QualifiedApplicationName convertFromText(String value, Class<?> targetType, String optionContext) { int colonIndex = value.indexOf(':'); if (colonIndex == -1) { throw new ShellException("Incorrect syntax. Valid syntax is '<ApplicationType>:<ApplicationName>'."); } ApplicationType applicationType = ApplicationType.valueOf(value.substring(0, colonIndex)); return new AppRegistryCommands.QualifiedApplicationName(value.substring(colonIndex + 1), applicationType); }
@Override public AbstractAppRegistryCommands.QualifiedApplicationName convertFromText(String value, Class<?> targetType, String optionContext) { int colonIndex = value.indexOf(':'); if (colonIndex == -1) { throw new ShellException("Incorrect syntax. Valid syntax is '<ApplicationType>:<ApplicationName>'."); } ApplicationType applicationType = ApplicationType.valueOf(value.substring(0, colonIndex)); return new AbstractAppRegistryCommands.QualifiedApplicationName(value.substring(colonIndex + 1), applicationType); }
@Override public Stream<AppRegistration> toValidAppRegistration(Map.Entry<String, URI> kv, URI metadataURI) { String key = kv.getKey(); String[] tokens = key.split("\\."); if (tokens.length == 2) { String name = tokens[1]; ApplicationType type = ApplicationType.valueOf(tokens[0]); URI appURI = warnOnMalformedURI(key, kv.getValue()); return Stream.of(new AppRegistration(name, type, "none", appURI, metadataURI)); } else { Assert.isTrue(tokens.length == 3 && METADATA_KEY_SUFFIX.equals(tokens[2]), "Invalid format for app key '" + key + "'in file. Must be <type>.<name> or <type>.<name>" + ".metadata"); return Stream.empty(); } }
private void validateAppVersionIsRegistered(String registeredAppName, AppDeploymentRequest appDeploymentRequest, String appVersion) { String appTypeString = appDeploymentRequest.getDefinition().getProperties() .get(DataFlowPropertyKeys.STREAM_APP_TYPE); ApplicationType applicationType = ApplicationType.valueOf(appTypeString); if (!this.appRegistryService.appExist(registeredAppName, applicationType, appVersion)) { throw new IllegalStateException(String.format("The %s:%s:%s app is not registered!", registeredAppName, appTypeString, appVersion)); } }
private void validateAppVersionIsRegistered(String registeredAppName, AppDeploymentRequest appDeploymentRequest, String appVersion) { String appTypeString = appDeploymentRequest.getDefinition().getProperties() .get(DataFlowPropertyKeys.STREAM_APP_TYPE); ApplicationType applicationType = ApplicationType.valueOf(appTypeString); if (!this.appRegistryService.appExist(registeredAppName, applicationType, appVersion)) { throw new IllegalStateException(String.format("The %s:%s:%s app is not registered!", registeredAppName, appTypeString, appVersion)); } }
/** * Builds a {@link Stream} from key/value mapping. * @return * <ul> * <li>valid AppRegistration as single element Stream</li> * <li>silently ignores well malformed metadata entries (0 element Stream) or</li> * <li>fails otherwise.</li> * </ul> * * @param kv key/value representing app key (key) and app URI (value) * @param metadataURI metadataUri computed from a given app key */ protected Stream<AppRegistration> toValidAppRegistration(Map.Entry<String, URI> kv, URI metadataURI) { String key = kv.getKey(); String[] tokens = key.split("\\."); if (tokens.length == 2) { String name = tokens[1]; ApplicationType type = ApplicationType.valueOf(tokens[0]); URI appURI = warnOnMalformedURI(key, kv.getValue()); String version = getVersionOrBroken(appURI.toString()); return Stream.of(new AppRegistration(name, type, version, appURI, metadataURI)); } else { Assert.isTrue(tokens.length == 3 && METADATA_KEY_SUFFIX.equals(tokens[2]), "Invalid format for app key '" + key + "'in file. Must be <type>.<name> or <type>.<name>" + ".metadata"); return Stream.empty(); } }
/** * Builds a {@link Stream} from key/value mapping. * @return * <ul> * <li>valid AppRegistration as single element Stream</li> * <li>silently ignores well malformed metadata entries (0 element Stream) or</li> * <li>fails otherwise.</li> * </ul> * * @param kv key/value representing app key (key) and app URI (value) * @param metadataURI metadataUri computed from a given app key */ protected Stream<AppRegistration> toValidAppRegistration(Map.Entry<String, URI> kv, URI metadataURI) { String key = kv.getKey(); String[] tokens = key.split("\\."); if (tokens.length == 2) { String name = tokens[1]; ApplicationType type = ApplicationType.valueOf(tokens[0]); URI appURI = warnOnMalformedURI(key, kv.getValue()); String version = getVersionOrBroken(appURI.toString()); return Stream.of(new AppRegistration(name, type, version, appURI, metadataURI)); } else { Assert.isTrue(tokens.length == 3 && METADATA_KEY_SUFFIX.equals(tokens[2]), "Invalid format for app key '" + key + "'in file. Must be <type>.<name> or <type>.<name>" + ".metadata"); return Stream.empty(); } }