List of usage examples for org.springframework.core.io Resource getURI
URI getURI() throws IOException;
From source file:org.beangle.ems.dev.hibernate.web.action.EvolutionAction.java
public String index() throws IOException { Resource[] resources = resolver.getResources("classpath*:db/" + databaseName + "/evolutions/**/*.sql"); String version = get("version"); if (null != version && !version.endsWith("/")) version += "/"; if (null != version && !version.startsWith("/")) version = "/" + version; if (Strings.isNotBlank(version)) { List<Resource> results = CollectUtils.newArrayList(); for (Resource resource : resources) { if (resource.getURI().toString().contains(version)) { results.add(resource);//ww w. j a v a 2 s . c om } } put("resources", results); } else { put("resources", resources); } put("databaseName", databaseName); return forward(); }
From source file:com.iisigroup.cap.message.CapReloadableResourceBundleMessageSource.java
@Override public void afterPropertiesSet() throws Exception { Set<String> l = new HashSet<String>(); String i18nPattern = basePath + "/**/*.properties"; String i18nFileREG = "(" + StringUtils.join(languages, '|') + ").properties$"; if (defaultLocale != null) {// w w w. ja v a 2s .co m Locale.setDefault(this.defaultLocale); } try { Resource[] resources = applicationContext.getResources(i18nPattern); for (Resource resource : resources) { String path = resource.getURI().toString(); if (CapString.checkRegularMatch(path, i18nFileREG)) { path = path.replaceAll(i18nFileREG, "").replaceAll(".*/i18n/", "classpath:/i18n/") // for windows .replaceAll(".*\\\\i18n\\\\", "classpath:\\\\i18n\\\\").replaceAll("\\\\", "/"); if (!l.contains(path)) { l.add(path); logger.debug("set message path:" + path); } } } } catch (Exception e) { logger.error(e.getMessage(), e); } super.setBasenames(l.toArray(new String[l.size()])); }
From source file:griffon.plugins.i18n.ExtendedResourceBundleMessageSource.java
private List<ResourceBundle> loadBundleForFilename(String filename) { List<ResourceBundle> bundles = new ArrayList<ResourceBundle>(); try {//from w w w . ja v a2 s.c o m Resource[] resources = resolver.getResources("classpath*:/" + filename + ".properties"); if (LOG.isTraceEnabled()) { LOG.trace("Found " + resources.length + " matches for classpath *:/" + filename + ".properties"); } for (Resource resource : resources) { if (LOG.isTraceEnabled()) LOG.trace("Initializing bundle with " + resource.getURI()); bundles.add(new PropertyResourceBundle(resource.getInputStream())); } } catch (IOException e) { // ignore } return bundles; }
From source file:com.jaxio.celerio.template.pack.ClasspathResourceUncryptedPack.java
public ClasspathResourceUncryptedPack(TemplatePackInfo templatePackInfo, Resource[] templatesAsResources) throws IOException { this.templatePackInfo = templatePackInfo; for (Resource r : templatesAsResources) { if (!isFolder(r)) { String templateName = r.getURI().toString(); String root = "celerio/" + templatePackInfo.getName() + "/"; templateName = normalize(templateName.substring(templateName.indexOf(root) + root.length())); templateNames.add(templateName); Template template = new Template(templateName, templatePackInfo, toByteArray(r.getInputStream())); templates.put(templateName, template); }//w ww . ja va2s. c o m } // Force execution order to natural ordering. // Important otherwise it behaves differently on Mac/Linux. // Note: thanks to Jean-LouisL Boudart for reporting this. Collections.sort(templateNames); }
From source file:org.bonitasoft.web.designer.workspace.WorkspaceTest.java
private void mockWidgetsBasePath(Path path) throws IOException { Resource resource = mock(Resource.class); when(resource.getURI()).thenReturn(path.toUri()); when(resourceLoader.getResource(WebMvcConfiguration.WIDGETS_RESOURCES)).thenReturn(resource); }
From source file:org.brekka.stillingar.spring.snapshot.WatchedResourceMonitor.java
@Override public boolean canMonitor(Resource resource) { try {//w ww . j av a2 s .co m return resource.getURI().getScheme().startsWith("file"); } catch (IOException e) { throw new ConfigurationException(String .format("Failed to test watcher for ability to monitor resource '%s'", resource.toString()), e); } }
From source file:org.bitsofinfo.util.io.DefaultRecordLoaderTest.java
@Test public void testRecordLoaderWithUSPSSample() { try {/*from www .j av a 2 s . co m*/ Resource file = applicationContext.getResource("classpath:usps.ais.zipPlus4.sample.txt"); FileHandle handle = new FileHandle(file.getURI()); // has CR/LF, so 182+1 chars List<String> line = recordLoader.loadRecords(handle, 7, 10, 182 + 1); int v = 1; } catch (Exception e) { e.printStackTrace(); int v = 1; } }
From source file:org.bitsofinfo.util.io.DefaultRecordLoaderTest.java
@Test public void testRecordLoaderWithZipInfoSample() { try {// www.j av a 2 s . c o m Resource file = applicationContext.getResource("classpath:zipinfo.com.usps.zipPlus4.sample.txt"); FileHandle handle = new FileHandle(file.getURI()); // no CR/LF present so straight 182 chars List<String> copyrightLine = recordLoader.loadRecords(handle, 1, 1, 182); List<String> lines = recordLoader.loadRecords(handle, 2, 1002, 182); Copyright copyright = parser.parseCopyright(copyrightLine.get(0)); List<USPSRecord> records = parser.parseData(USPSProductType.ZIP_PLUS_4, copyright, lines); int v = 1; } catch (Exception e) { e.printStackTrace(); int v = 1; } }
From source file:org.bitsofinfo.util.io.DefaultRecordLoaderTest.java
@Test public void testRecordLoaderWithZipInfoSampleGetAll() { try {/* www . ja v a 2 s . c om*/ Resource file = applicationContext.getResource("classpath:zipinfo.com.usps.zipPlus4.sample.txt"); FileHandle handle = new FileHandle(file.getURI()); // no CR/LF present so straight 182 chars List<String> copyrightLine = recordLoader.loadRecords(handle, 1, 1, 182); List<String> lines = recordLoader.loadRecords(handle, 2, 10000, 182); // get all Copyright copyright = parser.parseCopyright(copyrightLine.get(0)); List<USPSRecord> records = parser.parseData(USPSProductType.ZIP_PLUS_4, copyright, lines); assert (records.size() == 5074); } catch (Exception e) { e.printStackTrace(); int v = 1; } }
From source file:org.globus.security.stores.ResourceSecurityWrapperStore.java
private boolean loadResources(String locationPattern, Set<V> updatedList, Map<String, T> newWrapperMap) throws ResourceStoreException { boolean changed = false; try {//from w ww . j a va2 s . co m Resource[] resources = resolver.getResources(locationPattern); for (Resource resource : resources) { URI uri = resource.getURI(); if (!resource.isReadable()) { getLogger().warning("Cannot read: " + uri.toASCIIString()); continue; } changed = load(resource, updatedList, newWrapperMap); } } catch (IOException e) { throw new ResourceStoreException(e); } return changed; }