com.zhazhapan.util.Checker Java Examples
The following examples show how to use
com.zhazhapan.util.Checker.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QiniuService.java From qiniu with MIT License | 6 votes |
/** * 获取空间的流量统计,使用自定义单位 */ public XYChart.Series<String, Long> getBucketFlux(String[] domains, String startDate, String endDate, String unit) { // 获取流量数据 CdnResult.FluxResult fluxResult = null; try { fluxResult = sdkManager.getFluxData(domains, startDate, endDate); } catch (QiniuException e) { Platform.runLater(() -> DialogUtils.showException(QiniuValueConsts.BUCKET_FLUX_ERROR, e)); } // 设置图表 XYChart.Series<String, Long> series = new XYChart.Series<>(); series.setName(QiniuValueConsts.BUCKET_FLUX_COUNT.replaceAll("[A-Z]+", unit)); // 格式化数据 if (Checker.isNotNull(fluxResult) && Checker.isNotEmpty(fluxResult.data)) { long unitSize = Formatter.sizeToLong("1 " + unit); for (Map.Entry<String, CdnResult.FluxData> flux : fluxResult.data.entrySet()) { CdnResult.FluxData fluxData = flux.getValue(); if (Checker.isNotNull(fluxData)) { setSeries(fluxResult.time, fluxData.china, fluxData.oversea, series, unitSize); } } } return series; }
Example #2
Source File: MainController.java From visual-spider with MIT License | 6 votes |
/** * 连接到数据库 */ private void connectDatabase() { try { if (Checker.isNotNull(SpiderApplication.connection) && !SpiderApplication.connection.isClosed()) { SpiderApplication.connection.close(); } Class.forName("com.mysql.jdbc.Driver"); String url = "jdbc:mysql://" + MysqlConfig.getDbHost() + ":" + MysqlConfig.getDbPort() + "/" + MysqlConfig.getDbName() + "?" + MysqlConfig.getDbCondition(); SpiderApplication.connection = DriverManager.getConnection(url, MysqlConfig.getDbUsername(), MysqlConfig .getDbPassword()); SpiderApplication.statement = SpiderApplication.connection.createStatement(); LOGGER.info("database connect success"); MysqlConfig.setConnectionSuccessful(true); } catch (Exception e) { LOGGER.error(e.getMessage()); MysqlConfig.setConnectionSuccessful(false); Alerts.showError(SpiderValueConsts.MAIN_TITLE, e.getMessage()); } }
Example #3
Source File: CustomCrawlingController.java From visual-spider with MIT License | 6 votes |
@FXML private void initialize() { // 初始化自定义爬取,并设置默认值 SpiderApplication.customCrawlingController = this; mappings.setWrapText(true); dbHost.setText(MysqlConfig.getDbHost()); dbPort.setText(MysqlConfig.getDbPort()); dbCondition.setText(MysqlConfig.getDbCondition()); dbName.setText(MysqlConfig.getDbName()); dbPassword.setText(MysqlConfig.getDbPassword()); dbTable.setText(MysqlConfig.getTableName()); dbUsername.setText(MysqlConfig.getDbUsername()); if (Checker.isNotEmpty(MysqlConfig.getFields())) { StringBuilder sb = new StringBuilder(); for (Pair<String, String> pair : MysqlConfig.getFields()) { sb.append(pair.getKey()).append(" -> ").append(pair.getValue()).append(", "); } String mapping = sb.toString(); mappings.setText(mapping.substring(0, mapping.length() - 2)); } }
Example #4
Source File: AuthServiceImpl.java From efo with MIT License | 6 votes |
@Override public boolean addAuth(String files, String users, String auths) { if (Checker.isNotEmpty(files) && Checker.isNotEmpty(users) && Checker.isNotEmpty(auths)) { String[] file = files.split(ValueConsts.COMMA_SIGN); String[] user = users.split(ValueConsts.COMMA_SIGN); for (String f : file) { long fileId = Formatter.stringToLong(f); for (String u : user) { int userId = Formatter.stringToInt(u); if (Checker.isNull(authDAO.exists(userId, fileId))) { Auth auth = new Auth(userId, fileId); auth.setAuth(BeanUtils.getAuth(auths)); authDAO.insertAuth(auth); } } } } return true; }
Example #5
Source File: MainController.java From visual-spider with MIT License | 6 votes |
/** * 退出程序 */ public void exit() { if (crawling) { Optional<ButtonType> result = Alerts.showConfirmation(SpiderValueConsts.MAIN_TITLE, SpiderValueConsts .EXIT_CRAWLING); if (result.get() != ButtonType.OK) { return; } } saveLog(); // 关闭数据库连接 try { if (Checker.isNotNull(SpiderApplication.statement)) { SpiderApplication.statement.close(); } if (Checker.isNotNull(SpiderApplication.connection)) { SpiderApplication.connection.close(); } } catch (SQLException e) { LOGGER.error(e.getMessage()); } System.exit(0); }
Example #6
Source File: QiniuService.java From qiniu with MIT License | 6 votes |
/** * 处理带宽数据 */ private void setSeries(String[] times, Long[] china, Long[] oversea, XYChart.Series<String, Long> series, long unit) { int i = 0; for (String time : times) { long size = 0; if (Checker.isNotEmpty(china)) { size += china[i]; } if (Checker.isNotEmpty(oversea)) { size += oversea[i]; } series.getData().add(new XYChart.Data<>(time.substring(5, 10), size / unit)); i++; } }
Example #7
Source File: UserServiceImpl.java From efo with MIT License | 6 votes |
@Override public User login(String loginName, String password, String token, HttpServletResponse response) { boolean allowLogin = settings.getBooleanUseEval(ConfigConsts.ALLOW_LOGIN_OF_SETTINGS); User user = null; if (allowLogin) { if (Checker.isNotEmpty(token) && EfoApplication.tokens.containsKey(token)) { user = userDAO.getUserById(EfoApplication.tokens.get(token)); if (Checker.isNotNull(response)) { Cookie cookie = new Cookie(ValueConsts.TOKEN_STRING, TokenConfig.generateToken(token, user.getId ())); cookie.setMaxAge(30 * 24 * 60 * 60); response.addCookie(cookie); } } if (Checker.isNull(user) && Checker.isNotEmpty(loginName) && Checker.isNotEmpty(password)) { user = userDAO.login(loginName, password); if (Checker.isNotNull(user)) { TokenConfig.removeTokenByValue(user.getId()); } } updateUserLoginTime(user); } return user; }
Example #8
Source File: CommonServiceImpl.java From efo with MIT License | 6 votes |
@Override public String uploadAvatar(MultipartFile multipartFile) { if (!multipartFile.isEmpty()) { String name = RandomUtils.getRandomStringOnlyLowerCase(ValueConsts.SIXTEEN_INT) + ValueConsts.DOT_SIGN + FileExecutor.getFileSuffix(multipartFile.getOriginalFilename()); if (Checker.isImage(name) && multipartFile.getSize() < ValueConsts.MB * DefaultValues.TWO_INT) { String path = SettingConfig.getAvatarStoragePath() + ValueConsts.SEPARATOR + name; try { FileExecutor.writeByteArrayToFile(new File(path), multipartFile.getBytes()); return name; } catch (IOException e) { logger.error("upload avatar error: " + e.getMessage()); } } } return ""; }
Example #9
Source File: FileManagerServiceImpl.java From efo with MIT License | 6 votes |
@Override public JSONObject setPermission(JSONObject object) { if (Checker.isLinux()) { JSONArray array = object.getJSONArray("items"); int code = object.getInteger("permsCode"); for (Object file : array) { try { Runtime.getRuntime().exec("chmod -R " + code + " " + file.toString()); } catch (IOException e) { logger.error(e.getMessage()); return getBasicResponse(ValueConsts.FALSE); } } } return getBasicResponse(ValueConsts.TRUE); }
Example #10
Source File: FileManagerServiceImpl.java From efo with MIT License | 6 votes |
@Override public JSONObject upload(String destination, MultipartFile... files) { System.out.println(files.length); if (Checker.isNotEmpty(files)) { if (Checker.isWindows() && destination.length() < ValueConsts.TWO_INT) { destination = "C:"; } for (MultipartFile file : files) { if (Checker.isNotNull(file) && !file.isEmpty()) { try { file.transferTo(new File(destination + File.separator + file.getOriginalFilename())); } catch (IOException e) { logger.error(e.getMessage()); return getBasicResponse(ValueConsts.FALSE); } } } } return getBasicResponse(ValueConsts.TRUE); }
Example #11
Source File: MainController.java From qiniu with MIT License | 6 votes |
/** * 搜索资源文件,忽略大小写 */ public void searchFile() { ArrayList<FileBean> files = new ArrayList<>(); String search = Checker.checkNull(searchTF.getText()); dataLength = 0; dataSize = 0; // 正则匹配查询 Pattern pattern = Pattern.compile(search, Pattern.CASE_INSENSITIVE); for (FileBean file : resData) { if (pattern.matcher(file.getName()).find()) { files.add(file); dataLength++; dataSize += Formatter.sizeToLong(file.getSize()); } } countBucket(); resTV.setItems(FXCollections.observableArrayList(files)); }
Example #12
Source File: AuthSqlProvider.java From efo with MIT License | 6 votes |
public String getAuthBy(@Param("id") long id, @Param("userId") int userId, @Param("fileId") long fileId, @Param ("fileName") String fileName, @Param("offset") int offset) { String sql = new SQL() {{ SELECT("a.id,a.user_id,a.file_id,u.username,f.name file_name,f.local_url,a.is_downloadable,a" + "" + "" + ".is_uploadable,a.is_deletable,a.is_updatable,a.is_visible,a.create_time"); FROM("auth a"); JOIN("user u on u.id=a.user_id"); JOIN("file f on f.id=a.file_id"); if (id > 0) { WHERE("a.id=#{id}"); } if (userId > 0) { WHERE("u.id=#{userId}"); } if (fileId > 0) { WHERE("f.id=#{fileId}"); } else if (Checker.isNotEmpty(fileName)) { WHERE("f.local_url like '%" + fileName + "%'"); } ORDER_BY("a." + EfoApplication.settings.getStringUseEval(ConfigConsts.AUTH_ORDER_BY_OF_SETTINGS)); }}.toString(); int size = EfoApplication.settings.getIntegerUseEval(ConfigConsts.AUTH_PAGE_SIZE_OF_SETTINGS); return sql + " limit " + (offset * size) + "," + size; }
Example #13
Source File: UploadedSqlProvider.java From efo with MIT License | 6 votes |
/** * 生成一条上传记录表的查询语句 * * @param userId 用户编号 * @param fileId 文件编号 * * @return SQL语句 */ public String getDownloadBy(@Param("userId") int userId, @Param("fileId") long fileId, @Param("fileName") String fileName, @Param("categoryId") int categoryId, @Param("offset") int offset) { String sql = new SQL() {{ SELECT("f.id,f.user_id,u.username,u.email,f.name file_name,c.name category_name,f.local_url,f.visit_url," + "" + "" + "" + "f" + ".create_time"); FROM("file f"); JOIN("user u on f.user_id=u.id"); JOIN("category c on f.category_id=c.id"); if (userId > 0) { WHERE("f.user_id=#{userId}"); } if (fileId > 0) { WHERE("f.id=#{fileId}"); } else if (Checker.isNotEmpty(fileName)) { WHERE("f.local_url like '%" + fileName + "%'"); } if (categoryId > 0) { WHERE("c.id=#{categoryId}"); } ORDER_BY("f." + EfoApplication.settings.getStringUseEval(ConfigConsts.FILE_ORDER_BY_OF_SETTING)); }}.toString(); int size = EfoApplication.settings.getIntegerUseEval(ConfigConsts.FILE_PAGE_SIZE_OF_SETTING); return sql + " limit " + (offset * size) + "," + size; }
Example #14
Source File: DownloadedSqlProvider.java From efo with MIT License | 6 votes |
/** * 生成一条下载记录表的查询语句 * * @param userId 用户编号 * @param fileId 文件编号 * * @return SQL语句 */ public String getDownloadBy(@Param("userId") int userId, @Param("fileId") long fileId, @Param("fileName") String fileName, @Param("categoryId") int categoryId, @Param("offset") int offset) { String sql = new SQL() {{ SELECT("d.id,d.user_id,d.file_id,u.username,u.email,f.name file_name,c.name category_name,f.visit_url,d" + ".create_time"); FROM("download d"); JOIN("user u on d.user_id=u.id"); JOIN("file f on d.file_id=f.id"); JOIN("category c on f.category_id=c.id"); if (userId > 0) { WHERE("d.user_id=#{userId}"); } if (fileId > 0) { WHERE("d.file_id=#{fileId}"); } else if (Checker.isNotEmpty(fileName)) { WHERE("f.local_url like '%" + fileName + "%'"); } if (categoryId > 0) { WHERE("c.id=#{categoryId}"); } ORDER_BY("d." + EfoApplication.settings.getStringUseEval(ConfigConsts.DOWNLOAD_ORDER_BY_OF_SETTINGS)); }}.toString(); int size = EfoApplication.settings.getIntegerUseEval(ConfigConsts.DOWNLOAD_PAGE_SIZE_OF_SETTINGS); return sql + " limit " + (offset * size) + "," + size; }
Example #15
Source File: UserSqlProvider.java From efo with MIT License | 6 votes |
public String getUserBy(@Param("permission") int permission, @Param("condition") String condition, @Param ("offset") int offset) { String sql = new SQL() {{ SELECT("*"); FROM("user"); if (permission == DefaultValues.THREE_INT) { WHERE("permission<3"); } else if (permission == DefaultValues.TWO_INT) { WHERE("permission<2"); } else { WHERE("permission<0"); } if (Checker.isNotEmpty(condition)) { WHERE("username like '%" + condition + "%' or email like '%" + condition + "%' or real_name like '" + condition + "'"); } ORDER_BY(EfoApplication.settings.getStringUseEval(ConfigConsts.USER_ORDER_BY_OF_SETTINGS)); }}.toString(); int size = EfoApplication.settings.getIntegerUseEval(ConfigConsts.USER_PAGE_SIZE_OF_SETTINGS); return sql + " limit " + (offset * size) + "," + size; }
Example #16
Source File: MainController.java From qiniu with MIT License | 6 votes |
/** * 添加上传的文件,支持拖曳文件夹 */ private void appendFile(File[] files, boolean isRecursive) { if (Checker.isNotNull(files)) { for (File file : files) { if (file.isDirectory()) { if (isRecursive) { // 递归添加文件 if (recursiveCB.isSelected()) { appendFile(file.listFiles(), true); } } else { rootPath.add(file.getAbsolutePath()); appendFile(file.listFiles(), true); } } else if (!selectedFileTA.getText().contains(file.getAbsolutePath())) { selectedFileTA.insertText(0, file.getAbsolutePath() + "\r\n"); } } } }
Example #17
Source File: FileSqlProvider.java From efo with MIT License | 6 votes |
/** * 生成一条文件基本信息的查询语句 * * @param userId 用户编号 * @param fileId 文件编号 * * @return SQL语句 */ public String getBasicBy(@Param("userId") int userId, @Param("fileId") long fileId, @Param("fileName") String fileName, @Param("categoryId") int categoryId, @Param("offset") int offset) { String sql = new SQL() {{ SELECT("f.id,u.username,f.local_url,c.name category_name,f.visit_url,f.download_times," + "f" + "" + "" + ".create_time"); FROM("file f"); JOIN("user u on f.user_id=u.id"); JOIN("category c on f.category_id=c.id"); if (userId > 0) { WHERE("f.user_id=#{userId}"); } if (fileId > 0) { WHERE("f.id=#{fileId}"); } else if (Checker.isNotEmpty(fileName)) { WHERE("f.local_url like '%" + fileName + "%'"); } if (categoryId > 0) { WHERE("c.id=#{categoryId}"); } ORDER_BY("f." + EfoApplication.settings.getStringUseEval(ConfigConsts.FILE_ORDER_BY_OF_SETTING)); }}.toString(); int size = EfoApplication.settings.getIntegerUseEval(ConfigConsts.FILE_PAGE_SIZE_OF_SETTING); return sql + " limit " + (offset * size) + "," + size; }
Example #18
Source File: Crawler.java From visual-spider with MIT License | 6 votes |
/** * 判断需要下载的资源 * * @param url {@link URL} * @param html {@link String} */ public void downloadURL(String url, String html) { Matcher matcher; if (CrawlConfig.getCrawlImages().get()) { matcher = IMAGES_PATTERN.matcher(html); addURLs("image", matcher); } if (CrawlConfig.getCrawlVideos().get()) { matcher = VIDEOS_PATTERN.matcher(html); addURLs("media", matcher); } if (CrawlConfig.getCrawlDocs().get()) { matcher = DOCS_PATTERN.matcher(html); addURLs("document", matcher); } if (CrawlConfig.getCrawlOthers().get()) { matcher = OTHERS_PATTERN.matcher(html); addURLs("others", matcher); } if (Checker.isNotEmpty(url) && CrawlConfig.getCrawlLinks().get()) { String path = SpiderApplication.DOWNLOAD_FOLDER + SpiderValueConsts.SEPARATOR + "link"; Downloader.download(path, (url.startsWith("//") ? "http:" : "") + url); } customCrawling(url, html); }
Example #19
Source File: FileController.java From efo with MIT License | 6 votes |
@ApiOperation(value = "删除指定文件") @AuthInterceptor(InterceptorLevel.USER) @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) public String removeFile(@PathVariable("id") long id) { User user = (User) request.getSession().getAttribute(ValueConsts.USER_STRING); jsonObject.put("status", "error"); if (Checker.isNull(user)) { jsonObject.put("message", "请先登录"); } else if (id < 1) { jsonObject.put("message", "格式不合法"); } else if (fileService.removeFile(user, id)) { jsonObject.put("status", "success"); } else { jsonObject.put("message", "删除失败,权限不够,请联系管理员"); } return jsonObject.toString(); }
Example #20
Source File: QiniuService.java From qiniu with MIT License | 6 votes |
/** * 刷新文件 */ public void refreshFile(ObservableList<FileBean> fileBeans, String domain) { if (Checker.isNotEmpty(fileBeans)) { String[] files = new String[fileBeans.size()]; int i = 0; // 获取公有链接 for (FileBean fileBean : fileBeans) { files[i++] = QiniuUtils.buildUrl(fileBean.getName(), domain); } try { // 刷新文件 sdkManager.refreshFile(files); } catch (QiniuException e) { LOGGER.error("refresh files error, message -> " + e.getMessage()); DialogUtils.showException(e); } } }
Example #21
Source File: QiniuService.java From qiniu with MIT License | 6 votes |
/** * 日志下载 */ public void downloadCdnLog(String logDate) { if (Checker.isNotEmpty(QiniuApplication.getConfigBean().getBuckets()) && Checker.isDate(logDate)) { // 转换域名成数组格式 String[] domains = new String[QiniuApplication.getConfigBean().getBuckets().size()]; for (int i = 0; i < QiniuApplication.getConfigBean().getBuckets().size(); i++) { domains[i] = QiniuApplication.getConfigBean().getBuckets().get(i).getUrl(); } Map<String, CdnResult.LogData[]> cdnLog = null; try { cdnLog = sdkManager.listCdnLog(domains, logDate); } catch (QiniuException e) { DialogUtils.showException(e); } if (Checker.isNotEmpty(cdnLog)) { // 下载日志 for (Map.Entry<String, CdnResult.LogData[]> logs : cdnLog.entrySet()) { for (CdnResult.LogData log : logs.getValue()) { QiniuUtils.download(log.url); } } } } }
Example #22
Source File: QiniuService.java From qiniu with MIT License | 6 votes |
/** * 获取空间带宽统计,使用自定义单位 */ public XYChart.Series<String, Long> getBucketBandwidth(String[] domains, String startDate, String endDate, String unit) { // 获取带宽数据 CdnResult.BandwidthResult bandwidthResult = null; try { bandwidthResult = sdkManager.getBandwidthData(domains, startDate, endDate); } catch (QiniuException e) { Platform.runLater(() -> DialogUtils.showException(QiniuValueConsts.BUCKET_BAND_ERROR, e)); } // 设置图表 XYChart.Series<String, Long> series = new XYChart.Series<>(); series.setName(QiniuValueConsts.BUCKET_BANDWIDTH_COUNT.replaceAll("[A-Z]+", unit)); // 格式化数据 if (Checker.isNotNull(bandwidthResult) && Checker.isNotEmpty(bandwidthResult.data)) { long unitSize = Formatter.sizeToLong("1 " + unit); for (Map.Entry<String, CdnResult.BandwidthData> bandwidth : bandwidthResult.data.entrySet()) { CdnResult.BandwidthData bandwidthData = bandwidth.getValue(); if (Checker.isNotNull(bandwidthData)) { setSeries(bandwidthResult.time, bandwidthData.china, bandwidthData.oversea, series, unitSize); } } } return series; }
Example #23
Source File: UserController.java From efo with MIT License | 6 votes |
@ApiOperation(value = "登录(用户名密码和token必须有一个输入)") @ApiImplicitParams({@ApiImplicitParam(name = "username", value = "用户名"), @ApiImplicitParam(name = "password", value = "密码"), @ApiImplicitParam(name = "auto", value = "是否自动登录", dataType = "Boolean"), @ApiImplicitParam(name = "token", value = "用于自动登录")}) @AuthInterceptor(InterceptorLevel.NONE) @RequestMapping(value = "/login", method = RequestMethod.PUT) public String login(String username, String password, boolean auto, String token) { //使用密码登录 User user = userService.login(username, password, ValueConsts.NULL_STRING, ValueConsts.NULL_RESPONSE); if (Checker.isNull(user) || user.getPermission() < 1) { jsonObject.put("status", "failed"); } else { request.getSession().setAttribute(ValueConsts.USER_STRING, user); jsonObject.put("status", "success"); if (auto) { jsonObject.put("token", TokenConfig.generateToken(token, user.getId())); } else { jsonObject.put("token", ""); TokenConfig.removeTokenByValue(user.getId()); } } return jsonObject.toString(); }
Example #24
Source File: VsController.java From visual-spider with MIT License | 5 votes |
/** * 初始化 * * @param numberOfCrawlers 爬虫线程数 * @param maxDepthOfCrawling 抓取深度 * @param maxPagesToFetch 最大抓取页数 * @param politenessDelay 延迟 * @param links 待爬取链接 */ public void init(int numberOfCrawlers, int maxDepthOfCrawling, int maxPagesToFetch, int politenessDelay, String[] links) { this.numberOfCrawlers = numberOfCrawlers; CrawlConfig config = new CrawlConfig(); config.setCrawlStorageFolder(DefaultConfigValues.CRAWL_STORAGE_FOLDER); config.setMaxDepthOfCrawling(maxDepthOfCrawling); config.setIncludeHttpsPages(true); config.setMaxPagesToFetch(maxPagesToFetch); config.setIncludeBinaryContentInCrawling(false); config.setPolitenessDelay(politenessDelay); config.setUserAgentString(DefaultConfigValues.USER_AGENT); config.setResumableCrawling(true); if (com.zhazhapan.vspider.models.CrawlConfig.getTurnOnProxy().get()) { LOGGER.info("open proxy"); config.setProxyHost(com.zhazhapan.vspider.models.CrawlConfig.getProxyServer().get()); config.setProxyPort(Formatter.stringToInt(com.zhazhapan.vspider.models.CrawlConfig.getProxyPort().get())); config.setProxyUsername(com.zhazhapan.vspider.models.CrawlConfig.getProxyUser().get()); config.setProxyPassword(com.zhazhapan.vspider.models.CrawlConfig.getProxyPass().get()); } PageFetcher pageFetcher = new PageFetcher(config); RobotstxtConfig robotstxtConfig = new RobotstxtConfig(); robotstxtConfig.setEnabled(false); RobotstxtServer robotstxtServer = new RobotstxtServer(robotstxtConfig, pageFetcher); try { controller = new CrawlController(config, pageFetcher, robotstxtServer); for (String link : links) { if (Checker.isHyperLink(link)) { controller.addSeed(link); } } isInited = true; } catch (Exception e) { LOGGER.error("start to crawl urls error: " + e.getMessage()); } }
Example #25
Source File: Crawler.java From visual-spider with MIT License | 5 votes |
/** * 自定义爬取 * * @param html 内容 */ public void customCrawling(String url, String html) { boolean shouldCrawling = MysqlConfig.isEnableCustom() && SpiderApplication.downloadFilterPattern.matcher(url) .find() && Checker.isNotEmpty(MysqlConfig.getFields()); if (shouldCrawling) { StringBuilder preSlice = new StringBuilder("insert into " + MysqlConfig.getTableName() + "("); StringBuilder postSlice = new StringBuilder(" values("); for (Pair<String, String> pair : MysqlConfig.getFields()) { preSlice.append(pair.getValue()).append(","); postSlice.append("'").append(SpiderUtils.evaluate(pair.getKey(), html).replaceAll("'", "\\\\'")) .append("',"); } String pre = preSlice.toString(); String post = postSlice.toString(); String sql = pre.substring(0, pre.length() - 1) + ")" + post.substring(0, post.length() - 1) + ")"; if (MysqlConfig.isEnableSql()) { SpiderUtils.saveFile(DefaultConfigValues.SQL_PATH, sql + ";\r\n", true); } if (MysqlConfig.isConnectionSuccessful()) { try { SpiderApplication.statement.executeUpdate(sql); } catch (SQLException e) { logger.error(e.getMessage()); } } } }
Example #26
Source File: UserController.java From efo with MIT License | 5 votes |
@ApiOperation(value = "更新我的基本信息") @ApiImplicitParams({@ApiImplicitParam(name = "avatar", value = "头像(可空)"), @ApiImplicitParam(name = "realName", value = "真实姓名(可空)"), @ApiImplicitParam(name = "email", value = "邮箱(可空)"), @ApiImplicitParam(name = "code", value = "验证码(可空)")}) @AuthInterceptor(InterceptorLevel.USER) @RequestMapping(value = "/info", method = RequestMethod.PUT) public String updateBasicInfo(String avatar, String realName, String email, String code) { User user = (User) request.getSession().getAttribute(ValueConsts.USER_STRING); jsonObject.put("message", "保存成功"); boolean emilVerify = EfoApplication.settings.getBooleanUseEval(ConfigConsts.EMAIL_VERIFY_OF_SETTINGS); if (Checker.isNotEmpty(email) && !email.equals(user.getEmail())) { if (!emilVerify || isCodeValidate(code)) { if (userService.emailExists(email)) { jsonObject.put("message", "邮箱更新失败,该邮箱已经存在"); } else { user.setEmail(email); } } else { jsonObject.put("message", "邮箱更新失败,验证码校验失败"); } } if (userService.updateBasicInfoById(user.getId(), avatar, realName, user.getEmail())) { user.setAvatar(avatar); user.setRealName(realName); jsonObject.put("status", "success"); } else { jsonObject.put("message", "服务器发生错误,请稍后重新尝试"); } jsonObject.put("email", user.getEmail()); return jsonObject.toString(); }
Example #27
Source File: VsController.java From visual-spider with MIT License | 5 votes |
/** * 启动爬虫 * * @return 是否启动成功 */ public boolean start() { if (Checker.isNull(controller)) { return false; } else { controller.start(Crawler.class, numberOfCrawlers); return true; } }
Example #28
Source File: MainController.java From visual-spider with MIT License | 5 votes |
/** * 保存爬取日志 */ public void saveLog() { String visitingLog = htmlContent.getText(); if (Checker.isNotEmpty(visitingLog) && visitingLog.contains(SpiderValueConsts.VISITING_TIP)) { SpiderUtils.saveFile(SpiderApplication.DOWNLOAD_FOLDER + SpiderValueConsts.SEPARATOR + "visiting.log", visitingLog, ValueConsts.TRUE); } String downloadingLog = logOut.getText(); if (Checker.isNotEmpty(downloadingLog) && downloadingLog.contains(SpiderValueConsts.DOWNLOADING_TIP)) { SpiderUtils.saveFile(SpiderApplication.DOWNLOAD_FOLDER + SpiderValueConsts.SEPARATOR + "downloading.log", downloadingLog, ValueConsts.TRUE); } }
Example #29
Source File: BeanUtils.java From efo with MIT License | 5 votes |
/** * 将权限字符串装换成权限数组 * * @param auth 权限字符串 * * @return 权限数组 */ public static int[] getAuth(String auth) { int[] a = new int[5]; if (Checker.isNotEmpty(auth)) { String[] u = auth.split(ValueConsts.COMMA_SIGN); int len = Math.min(a.length, u.length); for (int i = 0; i < len; i++) { a[i] = Formatter.stringToInt(u[i]); } } return a; }
Example #30
Source File: MainController.java From qiniu with MIT License | 5 votes |
/** * 保存前缀 */ private void savePrefix(String key) { if (Checker.isNotEmpty(key) && !QiniuApplication.getConfigBean().getPrefixes().contains(key)) { Platform.runLater(() -> prefixCB.getItems().add(key)); QiniuApplication.getConfigBean().getPrefixes().add(key); ConfigUtils.writeConfig(); } }