public static boolean existsFile(String filePath) { FileObject fileObject = VFS.resolveFile(filePath); if (fileObject.isExist()) { return true; } return false; }
public FileObject getFileObject(String path) { FileObject fileObject = fileMap.get(path); if (fileObject == null && searchPathList.size() > 0) { for (String searchPath : searchPathList) { fileObject = VFS.resolveFile(String.format("%s%s", searchPath, path.replaceAll(BACKSLASH, SLASH + File.separator))); if (fileObject.isExist()) { addFileObject(path, fileObject); break; } } } return fileObject; }
public InputStream getResourceAsStream(String path) { if (fullContextFileRepository != null) { FileObject fileObject = fullContextFileRepository .getFileObject(path); if (fileObject != null && fileObject.isExist()) { return fileObject.getInputStream(); } } return originalContext.getResourceAsStream(path); }
public URL getResource(String path) throws MalformedURLException { if (fullContextFileRepository != null) { FileObject fileObject = fullContextFileRepository .getFileObject(path); if (fileObject != null && fileObject.isExist()) { return fileObject.getURL(); } } return originalContext.getResource(path); }
public URL getResource(String path) throws MalformedURLException { if(fullContextFileRepository!=null){ FileObject fileObject = fullContextFileRepository .getFileObject(path); if(fileObject != null && fileObject.isExist()){ return fileObject.getURL(); } } return orignalContext.getResource(path); }
public String getRealPath(String path) { if (fullContextFileRepository != null) { FileObject fileObject = fullContextFileRepository .getFileObject(path); if (fileObject != null && fileObject.isExist()) { return fileObject.getAbsolutePath(); } } return originalContext.getRealPath(path); }
public InputStream getResourceAsStream(String path) { if(fullContextFileRepository!=null){ FileObject fileObject = fullContextFileRepository .getFileObject(path); if(fileObject != null && fileObject.isExist()){ return fileObject.getInputStream(); } } return orignalContext.getResourceAsStream(path); }
public String getRealPath(String path) { if(fullContextFileRepository!=null){ FileObject fileObject = fullContextFileRepository .getFileObject(path); if(fileObject != null && fileObject.isExist()){ return fileObject.getAbsolutePath(); } } return orignalContext.getRealPath(path); }
public FileObject getFileObjectDetectLocale(String path) { StringBuilder sb = new StringBuilder(); sb.append(path.substring(0, path.lastIndexOf('.'))); sb.append("."); String locale = LocaleUtil.getContext().getLocale().toString(); sb.append(locale); sb.append(path.substring(path.lastIndexOf('.'))); FileObject fileObject = getFileObject(sb.toString()); if (fileObject != null && fileObject.isExist()) { LOGGER.logMessage(LogLevel.DEBUG, "找到并使用[{}]的[{}]语言文件:{}", path, locale, fileObject.getPath()); return fileObject; } return getFileObject(path); }
@Override public boolean isMatch(String urlString) { if (!super.isMatch(urlString)) return false; FileObject fileObject = fullContextFileRepository .getFileObject(urlString); //是否检查资源文件 return checkFileExists ? (fileObject != null && fileObject.isExist()) : true; }
private String findTemplatePath(String path) throws FileNotFoundException { FileObject fileObject = fullContextFileRepository .getFileObjectDetectLocale(path); if (fileObject != null && fileObject.isExist()) { return fileObject.getPath(); } else { int lastIndexSlash = path.lastIndexOf('/'); return getDefaultTemplatePath(path.substring(0, lastIndexSlash)); } }
public FileObject getFileObjectDetectLocale(String path) { StringBuffer sb = new StringBuffer(); sb.append(path.substring(0, path.lastIndexOf('.'))); sb.append("."); String locale = LocaleUtil.getContext().getLocale().toString(); sb.append(locale); sb.append(path.substring(path.lastIndexOf('.'))); FileObject fileObject = getFileObject(sb.toString()); if (fileObject != null&&fileObject.isExist()) { logger.logMessage(LogLevel.DEBUG, "找到并使用[{}]的[{}]语言文件:{}",path,locale,fileObject.getPath()); return fileObject; } return getFileObject(path); }
private String findTemplatePath(String path) throws FileNotFoundException { FileObject fileObject = fullContextFileRepository .getFileObjectDetectLocale(path); if (fileObject != null && fileObject.isExist()) { return fileObject.getPath(); } else { int lastIndexSlash = path.lastIndexOf('/'); return getDefaultTemplatePath(path.substring(0, lastIndexSlash)); } }
private void refreshScanPath() { Set<FileObject> classPaths = new HashSet<FileObject>(); for (String file : allScanningPath) { FileObject fileObject = VFS.resolveFile(file); if (fileObject.isExist() && fileObject.getSchemaProvider().getSchema().equals("file:")) { classPaths.add(fileObject); } } resolveClassPaths(classPaths); resolveDeletedFile(); }
private PrivateKey loadPrivateKey(XmlSignatureConfig config) throws Exception { String storeType = StringUtil.isEmpty(config.getPrivateStoreType()) ? KeyStore.getDefaultType() : config.getPrivateStoreType(); KeyStore keyStore = KeyStore.getInstance(storeType); FileObject file = VFS.resolveFile(config.getPrivateKeyPath()); if (!file.isExist()) { throw new Exception(String.format("[%s]没有找到匹配的私钥,请检查配置", config.getPrivateKeyPath())); } char[] password = config.getPassword().toCharArray(); keyStore.load(file.getInputStream(), password); return (PrivateKey) keyStore.getKey(config.getAlias(), password); }
private PublicKey loadPublicKey(XmlSignatureConfig config) throws Exception { String storeType = StringUtil.isEmpty(config.getPublicStoreType()) ? "X.509" : config.getPublicStoreType(); CertificateFactory cf = CertificateFactory.getInstance(storeType); FileObject file = VFS.resolveFile(config.getPublicKeyPath()); if (!file.isExist()) { throw new Exception(String.format("[%s]没有找到匹配的公钥,请检查配置", config.getPublicKeyPath())); } Certificate c = cf.generateCertificate(file.getInputStream()); return c.getPublicKey(); }
public InputStream getResourceStream(String source) { FileObject fileObject = fullContextFileRepository.getFileObject(source); if (fileObject == null || !fileObject.isExist()) { throw new ResourceNotFoundException(source); } return fileObject.getInputStream(); }
public InputStream getResourceStream(String source) { FileObject fileObject = fullContextFileRepository.getFileObject(source); if (fileObject == null || !fileObject.isExist()) { throw new ResourceNotFoundException(source); } return fileObject.getInputStream(); }
public void execute(Context context) { LOGGER.logMessage(LogLevel.INFO, "文件存在判断组件开始执行"); int code = FlowComponentConstants.DEFAULT_CODE; FileObject fileObject = VFS.resolveFile(filePath); if (fileObject.isExist()) { code = FlowComponentConstants.EXIST_CODE; } context.put(resultKey, code); LOGGER.logMessage(LogLevel.INFO, "文件存在判断组件执行结束"); }
/** * 获取文件大小 * * @param filePath * @return */ public static long getFileSize(String filePath) { FileObject fileObject = VFS.resolveFile(filePath); if (!fileObject.isExist()) { LOGGER.logMessage(LogLevel.ERROR, "文件:{0}不存在", filePath); throw new FlowComponentException( FlowComponentExceptionErrorCode.FILE_NOT_FOUND, filePath); } return fileObject.getSize(); } }