commit
4b91e41581
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||
<classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
|
||||
</classpath>
|
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>jfinal-demo</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path:
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
id="WebApp_ID" version="3.0">
|
||||
<display-name>jfinal-demo</display-name>
|
||||
<welcome-file-list>
|
||||
<welcome-file>index.html</welcome-file>
|
||||
<welcome-file>index.htm</welcome-file>
|
||||
<welcome-file>index.jsp</welcome-file>
|
||||
<welcome-file>default.html</welcome-file>
|
||||
<welcome-file>default.htm</welcome-file>
|
||||
<welcome-file>default.jsp</welcome-file>
|
||||
</welcome-file-list>
|
||||
|
||||
<!-- 添加至 web.xml 1.4 添加 java文件 在项目 src 目录下创建 com.platform.config 包,并在 包下创建 JfinalConfig
|
||||
文件, -->
|
||||
<filter>
|
||||
<filter-name>jfinalF</filter-name>
|
||||
<filter-class>com.jfinal.core.JFinalFilter</filter-class>
|
||||
<init-param>
|
||||
<param-name>configClass</param-name>
|
||||
<param-value>com.platform.config.JfinalConfig</param-value>
|
||||
</init-param>
|
||||
</filter>
|
||||
<filter-mapping>
|
||||
<filter-name>jfinalF</filter-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</filter-mapping>
|
||||
|
||||
</web-app>
|
@ -0,0 +1,37 @@
|
||||
package com.platform.config;
|
||||
|
||||
import com.jfinal.config.Constants;
|
||||
import com.jfinal.config.Handlers;
|
||||
import com.jfinal.config.Interceptors;
|
||||
import com.jfinal.config.JFinalConfig;
|
||||
import com.jfinal.config.Plugins;
|
||||
import com.jfinal.config.Routes;
|
||||
import com.platform.controller.GfsController;
|
||||
import com.platform.controller.HelloController;
|
||||
|
||||
public class JfinalConfig extends JFinalConfig {
|
||||
|
||||
@Override
|
||||
public void configConstant(Constants me) {
|
||||
me.setDevMode(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configHandler(Handlers me) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configInterceptor(Interceptors me) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configPlugin(Plugins me) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configRoute(Routes me) {
|
||||
me.add("/hello", HelloController.class);
|
||||
me.add("/gfs", GfsController.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.platform.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
import com.jfinal.core.Controller;
|
||||
import com.platform.entities.FolderNode;
|
||||
import com.platform.entities.VolumeEntity;
|
||||
import com.platform.utils.CacheTreeData;
|
||||
import com.platform.utils.getTreeDataByPath;
|
||||
|
||||
public class GfsController extends Controller {
|
||||
|
||||
/** gfs目录树形查询 */
|
||||
private getTreeDataByPath getFolder = new getTreeDataByPath();
|
||||
|
||||
/**
|
||||
* 首页-"/gfs"下没有匹配到的路径时的请求方法
|
||||
*/
|
||||
public void index() {
|
||||
renderText("hello gfs !");
|
||||
}
|
||||
|
||||
public void getAllvolume(){
|
||||
|
||||
List<VolumeEntity> volumeList = CacheTreeData.getVolumeList();
|
||||
if (null == volumeList) {
|
||||
JSONObject jsondata = JSONObject.fromObject(new ArrayList<VolumeEntity>());
|
||||
renderJson(jsondata.toString());
|
||||
}
|
||||
for (VolumeEntity volume : volumeList) {
|
||||
if (null != volume.getPath()) {
|
||||
// 获得 folder 目录
|
||||
List<FolderNode> list = new ArrayList<FolderNode>();
|
||||
FolderNode currNode = getFolder(volume.getPath());
|
||||
if (null != currNode && null != currNode.getChildNodes()) {
|
||||
list.addAll(currNode.getChildNodes());
|
||||
}
|
||||
volume.setFolder(list);
|
||||
}
|
||||
}
|
||||
JSONObject jsondata = JSONObject.fromObject(volumeList);
|
||||
renderJson(jsondata.toString());
|
||||
}
|
||||
|
||||
public FolderNode getFolder(String path) {
|
||||
FolderNode result = getFolder.findByPath(path);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.platform.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.sf.json.JSONObject;
|
||||
import com.jfinal.core.Controller;
|
||||
import com.platform.entities.FolderNode;
|
||||
import com.platform.form.baseForm;
|
||||
|
||||
public class HelloController extends Controller {
|
||||
|
||||
public void index() {
|
||||
renderText("hello jfinal index !");
|
||||
}
|
||||
|
||||
public void tojson() {
|
||||
renderText("hello jfinal tojson !");
|
||||
}
|
||||
|
||||
public void gain() {
|
||||
baseForm form = new baseForm();
|
||||
form.setId("12");
|
||||
form.setName("n3");
|
||||
|
||||
String base = getPara("jsondata");
|
||||
System.err.println(base);
|
||||
if (null != base) {
|
||||
FolderNode f = new FolderNode();
|
||||
f.setIsFolder(2);
|
||||
f.setName("1");
|
||||
f.setPath("/da");
|
||||
FolderNode f1 = new FolderNode();
|
||||
f1.setIsFolder(2);
|
||||
f1.setName("1");
|
||||
f1.setPath("/da");
|
||||
List<FolderNode> lis = new ArrayList<FolderNode>();
|
||||
lis.add(f1);
|
||||
f.setChildNodes(lis);
|
||||
JSONObject jsondata = JSONObject.fromObject(f);
|
||||
renderJson(jsondata.toString());
|
||||
}
|
||||
else {
|
||||
renderText("hello jfinal gaindata ! ");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package com.platform.entities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FolderNode {
|
||||
private String name;
|
||||
private int isFolder; // 1 is file and other integer is folder show children number
|
||||
private String path;
|
||||
private List<FolderNode> childNodes = new ArrayList<FolderNode>();
|
||||
|
||||
|
||||
public FolderNode() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
public FolderNode(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public FolderNode(String name, int isFolder) {
|
||||
this.name = name;
|
||||
this.isFolder = isFolder;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the isFolder
|
||||
*/
|
||||
public int getIsFolder() {
|
||||
return isFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isFolder the isFolder to set
|
||||
*/
|
||||
public void setIsFolder(int isFolder) {
|
||||
this.isFolder = isFolder;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public List<FolderNode> getChildNodes() {
|
||||
return childNodes;
|
||||
}
|
||||
|
||||
public void setChildNodes(List<FolderNode> childNodes) {
|
||||
this.childNodes = childNodes;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.platform.form;
|
||||
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.Introspector;
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Bean2MapUtils {
|
||||
|
||||
/**
|
||||
* 将一个 Map 对象转化为一个 JavaBean
|
||||
* @param type 要转化的类型
|
||||
* @param map 包含属性值的 map
|
||||
* @return 转化出来的 JavaBean 对象
|
||||
* @throws IntrospectionException
|
||||
* 如果分析类属性失败
|
||||
* @throws IllegalAccessException
|
||||
* 如果实例化 JavaBean 失败
|
||||
* @throws InstantiationException
|
||||
* 如果实例化 JavaBean 失败
|
||||
* @throws InvocationTargetException
|
||||
* 如果调用属性的 setter 方法失败
|
||||
*/
|
||||
public static Object convertMap(Class type, Map map)
|
||||
throws IntrospectionException, IllegalAccessException,
|
||||
InstantiationException, InvocationTargetException {
|
||||
BeanInfo beanInfo = Introspector.getBeanInfo(type); // 获取类属性
|
||||
Object obj = type.newInstance(); // 创建 JavaBean 对象
|
||||
|
||||
// 给 JavaBean 对象的属性赋值
|
||||
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
|
||||
for (int i = 0; i< propertyDescriptors.length; i++) {
|
||||
PropertyDescriptor descriptor = propertyDescriptors[i];
|
||||
String propertyName = descriptor.getName();
|
||||
try{
|
||||
if (map.containsKey(propertyName)) {
|
||||
// 下面一句可以 try 起来,这样当一个属性赋值失败的时候就不会影响其他属性赋值。
|
||||
Object value = map.get(propertyName);
|
||||
|
||||
Object[] args = new Object[1];
|
||||
args[0] = value;
|
||||
|
||||
descriptor.getWriteMethod().invoke(obj, args);
|
||||
}
|
||||
}
|
||||
catch(Exception e){
|
||||
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个 JavaBean 对象转化为一个 Map
|
||||
* @param bean 要转化的JavaBean 对象
|
||||
* @return 转化出来的 Map 对象
|
||||
* @throws IntrospectionException 如果分析类属性失败
|
||||
* @throws IllegalAccessException 如果实例化 JavaBean 失败
|
||||
* @throws InvocationTargetException 如果调用属性的 setter 方法失败
|
||||
*/
|
||||
public static Map convertBean(Object bean)
|
||||
throws IntrospectionException, IllegalAccessException, InvocationTargetException {
|
||||
Class type = bean.getClass();
|
||||
Map returnMap = new HashMap();
|
||||
BeanInfo beanInfo = Introspector.getBeanInfo(type);
|
||||
|
||||
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
|
||||
for (int i = 0; i< propertyDescriptors.length; i++) {
|
||||
PropertyDescriptor descriptor = propertyDescriptors[i];
|
||||
String propertyName = descriptor.getName();
|
||||
if (!propertyName.equals("class")) {
|
||||
Method readMethod = descriptor.getReadMethod();
|
||||
Object result = readMethod.invoke(bean, new Object[0]);
|
||||
if (result != null) {
|
||||
returnMap.put(propertyName, result);
|
||||
} else {
|
||||
returnMap.put(propertyName, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
return returnMap;
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.platform.form;
|
||||
|
||||
public class baseForm {
|
||||
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private baseForm base;
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the base
|
||||
*/
|
||||
public baseForm getBase() {
|
||||
return base;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param base the base to set
|
||||
*/
|
||||
public void setBase(baseForm base) {
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.platform.glusterfs;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.PropertyConfigurator;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.platform.utils.Constant;
|
||||
|
||||
|
||||
|
||||
public class RemoveData {
|
||||
|
||||
public static Logger log = Logger.getLogger ( RemoveData.class);
|
||||
|
||||
|
||||
/**
|
||||
* -1 :error; 0: the filename is not exists ; 1: right
|
||||
* @param folderName
|
||||
* @param fileName
|
||||
* @return
|
||||
*/
|
||||
public int deleteFolder(String folderName){
|
||||
log.info("start delete "+folderName);
|
||||
|
||||
ShowData showData=new ShowData();
|
||||
Map<String,String> reStrings=showData.showFolderData(folderName);
|
||||
|
||||
if(reStrings==null){
|
||||
log.error("3301 "+folderName+" is not exists");
|
||||
return -1;
|
||||
}
|
||||
|
||||
String command="rm -r "+folderName;
|
||||
|
||||
// int status=runCommand.runCommand(command);
|
||||
Constant.ganymedSSH.execCmdNoWaitAcquiescent(command);
|
||||
|
||||
log.info("delete "+folderName+" running");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeleteFolderFiles() {
|
||||
PropertyConfigurator.configure("log4j.properties");
|
||||
deleteFolder("/home/ubuntu");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.platform.entities.FolderNode;
|
||||
import com.platform.entities.VolumeEntity;
|
||||
|
||||
public class CacheTreeData {
|
||||
|
||||
private static List<FolderNode> folders = null;
|
||||
|
||||
private static List<VolumeEntity> volumeList = null;
|
||||
|
||||
public static List<FolderNode> getFolders() {
|
||||
return folders;
|
||||
}
|
||||
|
||||
public synchronized static void setFolders(List<FolderNode> folders) {
|
||||
CacheTreeData.folders = folders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the volumeList
|
||||
*/
|
||||
public static List<VolumeEntity> getVolumeList() {
|
||||
return volumeList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param volumeList the volumeList to set
|
||||
*/
|
||||
public synchronized static void setVolumeList(List<VolumeEntity> volumeList) {
|
||||
CacheTreeData.volumeList = volumeList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,50 @@
|
||||
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Constant {
|
||||
public static String rootUser = "root";
|
||||
public static String rootPasswd = "root";
|
||||
// public static String hostIp = "192.168.191.23";
|
||||
public static String hostIp = "";
|
||||
public static int port = 22;
|
||||
public static String glusterPeerStatus = "gluster peer status";
|
||||
public static String glusterVolumeInfo = "gluster volume info ";
|
||||
public static String df = "df -k ";
|
||||
public static String peerincluster_connected = "PeerinCluster(Connected)";
|
||||
public static String peerincluster_disconnected = "PeerinCluster(Disconnected)";
|
||||
public static String peerNotinCluster = "PeerNotinCluster";
|
||||
public static String distributed = "distributed";
|
||||
public static String replica = "replica";
|
||||
public static String stripe = "stripe";
|
||||
public static String noVolume = "No volumes present";
|
||||
public static String success = "success";
|
||||
public static String failed = "failed";
|
||||
public static String noSuchFile = "No such file or directory";
|
||||
public static GanymedSSH ganymedSSH = null;
|
||||
public static String fileGetTreeData = "WebContent\\WEB-INF\\config\\getTreedata.sh";
|
||||
public static String AutoMountfile="/gfsAutoMount/AutoRun.sh";
|
||||
public static String MountRecord="/gfsAutoMount/mountPoint.record";
|
||||
public static String strGetTreeData = "function ergodic(){\n "
|
||||
+ "for file in \\`ls \\$1\\`\n do\n if [ \"\\$file\" != \"app\" -a -d \\$1\\\"/\\\"\\$file ]\n "
|
||||
+ "then\n ergodic \\$1\"/\"\\$file\n else\n local path=\\$1\"/\"\\$file\n "
|
||||
+ "echo \\$path \n fi\n done\n}\n\nIFS=\\$\\'\\n\\' "
|
||||
+ "#这个必须要,否则会在文件名中有空格时出错\nINIT_PATH=\".\";\nergodic \\$1\n";
|
||||
|
||||
/**
|
||||
* volume 获取的线程休眠时间
|
||||
*/
|
||||
public final static int moveFileMaxNum = 1;
|
||||
|
||||
/**
|
||||
* volume 获取的线程休眠时间
|
||||
*/
|
||||
public final static int get_volume_sleep_time = 10000;
|
||||
|
||||
/**
|
||||
* volume 获取的线程休眠时间
|
||||
*/
|
||||
public final static int update_dataInfo_sleep_time = 1500;
|
||||
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 文件读写操作帮助类
|
||||
*
|
||||
* @author wuming
|
||||
*
|
||||
*/
|
||||
public class FileOperateHelper {
|
||||
|
||||
/**
|
||||
* 以追加的方式将信息写入文件
|
||||
*
|
||||
* @param path
|
||||
* @param message
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
public static void fileWrite(String path, String message) {
|
||||
if (null == path || "".equals(path)) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
path = path+".log";
|
||||
File file = new File(path);
|
||||
if (file.exists())
|
||||
file.createNewFile();
|
||||
FileOutputStream out = new FileOutputStream(file, true); // 如果追加方式用true
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(message);
|
||||
out.write(sb.toString().getBytes("utf-8"));
|
||||
} catch (IOException e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件读取方法
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("resource")
|
||||
public static String fileReader(String path) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String tempString = "";
|
||||
try {
|
||||
File file = new File(path);
|
||||
if (!file.exists())
|
||||
return "当前没有日志信息!";
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(fis,"UTF-8"));
|
||||
while ((tempString = br.readLine()) != null) {
|
||||
sb.append(tempString).append("\r\n");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Configs.CONSOLE_LOGGER.info(e.getMessage());
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件读取方法
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
public static String fileReaderAndendline(String path) {
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String tempString = "";
|
||||
try {
|
||||
File file = new File(path);
|
||||
if (!file.exists())
|
||||
|
||||
return "";
|
||||
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
|
||||
while ((tempString = br.readLine()) != null) {
|
||||
sb.append(tempString+"\n");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.platform.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.platform.entities.FolderNode;
|
||||
|
||||
public class getTreeDataByPath {
|
||||
|
||||
/**
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public FolderNode findByPath(String path) {
|
||||
List<FolderNode> folderNodelist = CacheTreeData.getFolders();
|
||||
if (null == folderNodelist) {
|
||||
return null;
|
||||
}
|
||||
FolderNode folder = null;
|
||||
for (FolderNode folderNode : folderNodelist) {
|
||||
folder = getFolder(folderNode, path);
|
||||
if (null != folder) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param f
|
||||
* @return
|
||||
*/
|
||||
private FolderNode getFolder(FolderNode f, String path){
|
||||
FolderNode result = null;
|
||||
if(path.equals(f.getPath())){
|
||||
return f;
|
||||
}
|
||||
List<FolderNode> folds = f.getChildNodes();
|
||||
if (null != folds) {
|
||||
for (FolderNode folderNode : folds) {
|
||||
result = getFolder(folderNode, path);
|
||||
if (null != result) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue