/** * Write config resources to disk. * * @param dependency the dependency * @param config the config * @param outputLocation the output location * @throws IOException Signals that an I/O exception has occurred. */ public static void writeConfigResourcesToDisk( Dependency dependency, List<ConfigurationResource> config, File outputLocation) throws IOException { String value = null; TransferSignature.ValueType valueType = null; for (ConfigurationResource portRef : config) { if (portRef.getReferableResource().getId().equals(dependency.getId())) { value = portRef.getValue(); ConfigurationResource.RefTypes refType = portRef.getRefType(); System.out.println("Value for " + portRef.getId() + " : " + value); if (refType == ConfigurationResource.RefTypes.INLINE_REF) { valueType = TransferSignature.ValueType.INLINE_STRING; } else if (refType == ConfigurationResource.RefTypes.URI_REF) { File success = download(value, new File("."), null); if (success.exists()) { System.out.println("Fetched " + value + " to " + success.getAbsolutePath()); value = success.getAbsolutePath(); } else { System.out.println("Failed to fetch " + value); } valueType = TransferSignature.ValueType.INLINE_URI; } else if (refType == ConfigurationResource.RefTypes.FILE_REF) { valueType = TransferSignature.ValueType.BUNDLED_FILE; // File tempFile = DataUtils.extractToTempFile(portRef); File tempFile = writeConfigurationResourceToFile(portRef, null, outputLocation); value = tempFile.getAbsolutePath(); } } } }
/** * Gets the configuration resource for dependency. * * @param dependency the dependency * @return the configuration resource for dependency */ public ConfigurationResource getConfigurationResourceForDependency(Dependency dependency) { for (Mapping mapping : concreteBundle.getPrimaryMappings()) { for (ConfigurationResource configurationResource : mapping.getResources()) { if (dependency.getId().equals(configurationResource.getId())) { return configurationResource; } } } return null; }