public InputStream getResource(String configName, String defaultUri) throws IllegalArgumentException, IOException { return getResource(defaultUri); }
public InputStream getResource(String configName, String defaultUri) throws IllegalArgumentException, IOException { return getResource(defaultUri); }
public InputStream getResource(String configName, String defaultUri) throws IllegalArgumentException, IOException { return getResource(defaultUri); }
@Override public InputStream getResourceAsStream(String name) { try { return new URIResourceLocator().getResource(name); } catch (IOException e) { return null; } } }
@Override public InputStream getResourceAsStream(String name) { try { return new URIResourceLocator().getResource(name); } catch (IOException e) { return null; } } }
/** * Get the actual mapping configuration data (the XML). * @param resourceLocator Resource locator used to open the config stream. * @param mappingConfig Mapping config path. * * @return The mapping configuration data stream. */ private static InputStream getMappingConfigData(URIResourceLocator resourceLocator, String mappingConfig) { InputStream configStream = null; try { configStream = resourceLocator.getResource(mappingConfig); } catch (IOException e) { IllegalStateException state = new IllegalStateException("Invalid EDI mapping model config specified for " + EDIParser.class.getName() + ". Unable to access URI based mapping model [" + resourceLocator.resolveURI(mappingConfig) + "]."); state.initCause(e); throw state; } return configStream; }
/** * Get the actual mapping configuration data (the XML). * @param resourceLocator Resource locator used to open the config stream. * @param mappingConfig Mapping config path. * * @return The mapping configuration data stream. */ private static InputStream getMappingConfigData(URIResourceLocator resourceLocator, String mappingConfig) { InputStream configStream = null; try { configStream = resourceLocator.getResource(mappingConfig); } catch (IOException e) { IllegalStateException state = new IllegalStateException("Invalid EDI mapping model config specified for " + EDIParser.class.getName() + ". Unable to access URI based mapping model [" + resourceLocator.resolveURI(mappingConfig) + "]."); state.initCause(e); throw state; } return configStream; }
/** * Get the actual mapping configuration data (the XML). * @param resourceLocator Resource locator used to open the config stream. * @param mappingConfig Mapping config path. * * @return The mapping configuration data stream. */ private static InputStream getMappingConfigData(URIResourceLocator resourceLocator, String mappingConfig) { InputStream configStream = null; try { configStream = resourceLocator.getResource(mappingConfig); } catch (IOException e) { IllegalStateException state = new IllegalStateException("Invalid EDI mapping model config specified for " + EDIParser.class.getName() + ". Unable to access URI based mapping model [" + resourceLocator.resolveURI(mappingConfig) + "]."); state.initCause(e); throw state; } return configStream; }
/** * Get the actual mapping configuration data (the XML). * @param resourceLocator Resource locator used to open the config stream. * @param mappingConfig Mapping config path. * * @return The mapping configuration data stream. */ private static InputStream getMappingConfigData(URIResourceLocator resourceLocator, String mappingConfig) { InputStream configStream = null; try { configStream = resourceLocator.getResource(mappingConfig); } catch (IOException e) { IllegalStateException state = new IllegalStateException("Invalid EDI mapping model config specified for " + EDIParser.class.getName() + ". Unable to access URI based mapping model [" + resourceLocator.resolveURI(mappingConfig) + "]."); state.initCause(e); throw state; } return configStream; }
public InputStream getResource(String uri) throws IllegalArgumentException, IOException { ResolvedURI resolvedURI = new ResolvedURI(uri, resolveURI(uri)); return getResource(resolvedURI); }
public InputStream getResource(String uri) throws IllegalArgumentException, IOException { ResolvedURI resolvedURI = new ResolvedURI(uri, resolveURI(uri)); return getResource(resolvedURI); }
public InputStream getResource(String uri) throws IllegalArgumentException, IOException { ResolvedURI resolvedURI = new ResolvedURI(uri, resolveURI(uri)); return getResource(resolvedURI); }
private static boolean loadZippedMappingModels(String mappingModelFile, Map<String, EdifactModel> mappingModels, URI baseURI) throws IOException, SAXException, EDIConfigurationException { URIResourceLocator locator = new URIResourceLocator(); locator.setBaseURI(baseURI); InputStream rawZipStream = locator.getResource(mappingModelFile); if(rawZipStream != null) { Archive archive = loadArchive(rawZipStream); if(archive != null) { List<String> rootMappingModels = getMappingModelList(archive); if(rootMappingModels.isEmpty()) { logger.debug("Configured mapping model file '" + mappingModelFile + "' is not a valid Mapping Model zip file. Check that the zip has a valid '" + EDI_MAPPING_MODEL_ZIP_LIST_FILE + "' mapping list file."); return false; } ClassLoader threadCCL = Thread.currentThread().getContextClassLoader(); try { ArchiveClassLoader archiveClassLoader = new ArchiveClassLoader(threadCCL, archive); Thread.currentThread().setContextClassLoader(archiveClassLoader); loadMappingModels(mappingModels, baseURI, rootMappingModels); } finally { Thread.currentThread().setContextClassLoader(threadCCL); } return true; } } return false; }
private static boolean loadZippedMappingModels(String mappingModelFile, Map<String, EdifactModel> mappingModels, URI baseURI) throws IOException, SAXException, EDIConfigurationException { URIResourceLocator locator = new URIResourceLocator(); locator.setBaseURI(baseURI); InputStream rawZipStream = locator.getResource(mappingModelFile); if(rawZipStream != null) { Archive archive = loadArchive(rawZipStream); if(archive != null) { List<String> rootMappingModels = getMappingModelList(archive); if(rootMappingModels.isEmpty()) { logger.debug("Configured mapping model file '" + mappingModelFile + "' is not a valid Mapping Model zip file. Check that the zip has a valid '" + EDI_MAPPING_MODEL_ZIP_LIST_FILE + "' mapping list file."); return false; } ClassLoader threadCCL = Thread.currentThread().getContextClassLoader(); try { ArchiveClassLoader archiveClassLoader = new ArchiveClassLoader(threadCCL, archive); Thread.currentThread().setContextClassLoader(archiveClassLoader); loadMappingModels(mappingModels, baseURI, rootMappingModels); } finally { Thread.currentThread().setContextClassLoader(threadCCL); } return true; } } return false; }
private static boolean loadZippedMappingModels(String mappingModelFile, Map<String, EdifactModel> mappingModels, URI baseURI) throws IOException, SAXException, EDIConfigurationException { URIResourceLocator locator = new URIResourceLocator(); locator.setBaseURI(baseURI); InputStream rawZipStream = locator.getResource(mappingModelFile); if(rawZipStream != null) { Archive archive = loadArchive(rawZipStream); if(archive != null) { List<String> rootMappingModels = getMappingModelList(archive); if(rootMappingModels.isEmpty()) { logger.debug("Configured mapping model file '" + mappingModelFile + "' is not a valid Mapping Model zip file. Check that the zip has a valid '" + EDI_MAPPING_MODEL_ZIP_LIST_FILE + "' mapping list file."); return false; } ClassLoader threadCCL = Thread.currentThread().getContextClassLoader(); try { ArchiveClassLoader archiveClassLoader = new ArchiveClassLoader(threadCCL, archive); Thread.currentThread().setContextClassLoader(archiveClassLoader); loadMappingModels(mappingModels, baseURI, rootMappingModels); } finally { Thread.currentThread().setContextClassLoader(threadCCL); } return true; } } return false; }
private static boolean loadZippedMappingModels(String mappingModelFile, Map<String, EdifactModel> mappingModels, URI baseURI) throws IOException, SAXException, EDIConfigurationException { URIResourceLocator locator = new URIResourceLocator(); locator.setBaseURI(baseURI); InputStream rawZipStream = locator.getResource(mappingModelFile); if(rawZipStream != null) { Archive archive = loadArchive(rawZipStream); if(archive != null) { List<String> rootMappingModels = getMappingModelList(archive); if(rootMappingModels.isEmpty()) { logger.debug("Configured mapping model file '" + mappingModelFile + "' is not a valid Mapping Model zip file. Check that the zip has a valid '" + EDI_MAPPING_MODEL_ZIP_LIST_FILE + "' mapping list file."); return false; } ClassLoader threadCCL = Thread.currentThread().getContextClassLoader(); try { ArchiveClassLoader archiveClassLoader = new ArchiveClassLoader(threadCCL, archive); Thread.currentThread().setContextClassLoader(archiveClassLoader); loadMappingModels(mappingModels, baseURI, rootMappingModels); } finally { Thread.currentThread().setContextClassLoader(threadCCL); } return true; } } return false; }
/** * Add a set of resource configurations to this Smooks instance. * <p/> * Uses the {@link org.milyn.resource.URIResourceLocator} class to load the resource. * <p/> * These configurations do not overwrite previously added configurations. * They are added to the list of configurations on this Smooks instance. * * @param resourceURI The URI string for the resource configuration list. See * {@link org.milyn.resource.URIResourceLocator}. * @throws IOException Error reading resource stream. * @throws SAXException Error parsing the resource stream. */ public void addConfigurations(String resourceURI) throws IOException, SAXException { AssertArgument.isNotNullAndNotEmpty(resourceURI, "resourceURI"); InputStream resourceConfigStream; URIResourceLocator resourceLocator = new URIResourceLocator(); resourceConfigStream = resourceLocator.getResource(resourceURI); try { URI resourceURIObj = new URI(resourceURI); addConfigurations(URIUtil.getParent(resourceURIObj).toString(), resourceConfigStream); } catch (URISyntaxException e) { logger.error("Failed to load Smooks resource configuration '" + resourceURI + "'.", e); } finally { resourceConfigStream.close(); } }
/** * Add a set of resource configurations to this Smooks instance. * <p/> * Uses the {@link org.milyn.resource.URIResourceLocator} class to load the resource. * <p/> * These configurations do not overwrite previously added configurations. * They are added to the list of configurations on this Smooks instance. * * @param resourceURI The URI string for the resource configuration list. See * {@link org.milyn.resource.URIResourceLocator}. * @throws IOException Error reading resource stream. * @throws SAXException Error parsing the resource stream. */ public void addConfigurations(String resourceURI) throws IOException, SAXException { AssertArgument.isNotNullAndNotEmpty(resourceURI, "resourceURI"); InputStream resourceConfigStream; URIResourceLocator resourceLocator = new URIResourceLocator(); resourceConfigStream = resourceLocator.getResource(resourceURI); try { URI resourceURIObj = new URI(resourceURI); addConfigurations(URIUtil.getParent(resourceURIObj).toString(), resourceConfigStream); } catch (URISyntaxException e) { logger.error("Failed to load Smooks resource configuration '" + resourceURI + "'.", e); } finally { resourceConfigStream.close(); } }
/** * Add a set of resource configurations to this Smooks instance. * <p/> * Uses the {@link org.milyn.resource.URIResourceLocator} class to load the resource. * <p/> * These configurations do not overwrite previously added configurations. * They are added to the list of configurations on this Smooks instance. * * @param resourceURI The URI string for the resource configuration list. See * {@link org.milyn.resource.URIResourceLocator}. * @throws IOException Error reading resource stream. * @throws SAXException Error parsing the resource stream. */ public void addConfigurations(String resourceURI) throws IOException, SAXException { AssertArgument.isNotNullAndNotEmpty(resourceURI, "resourceURI"); InputStream resourceConfigStream; URIResourceLocator resourceLocator = new URIResourceLocator(); resourceConfigStream = resourceLocator.getResource(resourceURI); try { URI resourceURIObj = new URI(resourceURI); addConfigurations(URIUtil.getParent(resourceURIObj).toString(), resourceConfigStream); } catch (URISyntaxException e) { logger.error("Failed to load Smooks resource configuration '" + resourceURI + "'.", e); } finally { resourceConfigStream.close(); } }
/** * Add a set of resource configurations to this Smooks instance. * * Uses the {@link org.milyn.resource.URIResourceLocator} class to load the resource. * * These configurations do not overwrite previously added configurations. * They are added to the list of configurations on this Smooks instance. * * @param resourceURI The URI string for the resource configuration list. See * {@link org.milyn.resource.URIResourceLocator}. * @throws IOException Error reading resource stream. * @throws SAXException Error parsing the resource stream. */ public void addConfigurations(String resourceURI) throws IOException, SAXException { AssertArgument.isNotNullAndNotEmpty(resourceURI, "resourceURI"); InputStream resourceConfigStream; URIResourceLocator resourceLocator = new URIResourceLocator(); resourceConfigStream = resourceLocator.getResource(resourceURI); try { URI resourceURIObj = new URI(resourceURI); addConfigurations(URIUtil.getParent(resourceURIObj).toString(), resourceConfigStream); } catch (URISyntaxException e) { logger.error("Failed to load Smooks resource configuration '" + resourceURI + "'.", e); } finally { resourceConfigStream.close(); } }