@Override public PackageConfiguration responseMessageForPackageConfiguration(String responseBody) { try { PackageConfiguration packageConfiguration = new PackageConfiguration(); Map<String, Map> configurations; try { configurations = parseResponseToMap(responseBody); } catch (Exception e) { throw new RuntimeException("Package configuration should be returned as a map"); } if (configurations == null || configurations.isEmpty()) { throw new RuntimeException("Empty response body"); } for (String key : configurations.keySet()) { if (isEmpty(key)) { throw new RuntimeException("Package configuration key cannot be empty"); } if (!(configurations.get(key) instanceof Map)) { throw new RuntimeException(format("Package configuration properties for key '%s' should be represented as a Map", key)); } packageConfiguration.add(toPackageMaterialProperty(key, configurations.get(key))); } return packageConfiguration; } catch (RuntimeException e) { throw new RuntimeException(format("Unable to de-serialize json response. %s", e.getMessage())); } }
@Override public RepositoryConfiguration responseMessageForRepositoryConfiguration(String responseBody) { try { RepositoryConfiguration repositoryConfiguration = new RepositoryConfiguration(); Map<String, Map> configurations; try { configurations = parseResponseToMap(responseBody); } catch (Exception e) { throw new RuntimeException("Repository configuration should be returned as a map"); } if (configurations == null || configurations.isEmpty()) { throw new RuntimeException("Empty response body"); } for (String key : configurations.keySet()) { if (isEmpty(key)) { throw new RuntimeException("Repository configuration key cannot be empty"); } if (!(configurations.get(key) instanceof Map)) { throw new RuntimeException(format("Repository configuration properties for key '%s' should be represented as a Map", key)); } repositoryConfiguration.add(toPackageMaterialProperty(key, configurations.get(key))); } return repositoryConfiguration; } catch (Exception e) { throw new RuntimeException(format("Unable to de-serialize json response. %s", e.getMessage())); } }
Map map; try { map = parseResponseToMap(responseBody); } catch (Exception e) { throw new RuntimeException("Package revision should be returned as a map");