sunlightcs 7 vuotta sitten
vanhempi
commit
630bb5305a
100 muutettua tiedostoa jossa 3809 lisäystä ja 7634 poistoa
  1. 6 0
      README.md
  2. 3 2
      doc/db.sql
  3. 4 11
      pom-war.xml
  4. 10 17
      pom.xml
  5. 40 0
      src/main/java/io/renren/common/aspect/RedisAspect.java
  6. 36 17
      src/main/java/io/renren/common/aspect/SysLogAspect.java
  7. 15 0
      src/main/java/io/renren/common/utils/RedisKeys.java
  8. 93 0
      src/main/java/io/renren/common/utils/RedisUtils.java
  9. 5 2
      src/main/java/io/renren/common/validator/ValidatorUtils.java
  10. 0 84
      src/main/java/io/renren/config/FastDFSConfig.java
  11. 57 0
      src/main/java/io/renren/config/RedisConfig.java
  12. 2 7
      src/main/java/io/renren/config/ShiroConfig.java
  13. 0 10
      src/main/java/io/renren/modules/api/controller/ApiLoginController.java
  14. 0 10
      src/main/java/io/renren/modules/api/controller/ApiRegisterController.java
  15. 10 10
      src/main/java/io/renren/modules/api/controller/ApiTestController.java
  16. 1 1
      src/main/java/io/renren/modules/job/entity/ScheduleJobEntity.java
  17. 1 1
      src/main/java/io/renren/modules/sys/controller/SysConfigController.java
  18. 10 2
      src/main/java/io/renren/modules/sys/controller/SysLoginController.java
  19. 10 30
      src/main/java/io/renren/modules/sys/controller/SysMenuController.java
  20. 1 1
      src/main/java/io/renren/modules/sys/dao/SysConfigDao.java
  21. 10 0
      src/main/java/io/renren/modules/sys/entity/SysLogEntity.java
  22. 38 0
      src/main/java/io/renren/modules/sys/redis/SysConfigRedis.java
  23. 1 2
      src/main/java/io/renren/modules/sys/service/SysConfigService.java
  24. 1 3
      src/main/java/io/renren/modules/sys/service/SysLogService.java
  25. 6 2
      src/main/java/io/renren/modules/sys/service/SysUserTokenService.java
  26. 23 7
      src/main/java/io/renren/modules/sys/service/impl/SysConfigServiceImpl.java
  27. 0 5
      src/main/java/io/renren/modules/sys/service/impl/SysLogServiceImpl.java
  28. 12 5
      src/main/java/io/renren/modules/sys/service/impl/SysUserTokenServiceImpl.java
  29. 0 472
      src/main/java/org/csource/common/Base64.java
  30. 0 190
      src/main/java/org/csource/common/IniFileReader.java
  31. 0 26
      src/main/java/org/csource/common/MyException.java
  32. 0 55
      src/main/java/org/csource/common/NameValuePair.java
  33. 0 201
      src/main/java/org/csource/fastdfs/ClientGlobal.java
  34. 0 26
      src/main/java/org/csource/fastdfs/DownloadCallback.java
  35. 0 49
      src/main/java/org/csource/fastdfs/DownloadStream.java
  36. 0 125
      src/main/java/org/csource/fastdfs/FileInfo.java
  37. 0 554
      src/main/java/org/csource/fastdfs/ProtoCommon.java
  38. 0 52
      src/main/java/org/csource/fastdfs/ProtoStructDecoder.java
  39. 0 66
      src/main/java/org/csource/fastdfs/ServerInfo.java
  40. 0 2076
      src/main/java/org/csource/fastdfs/StorageClient.java
  41. 0 799
      src/main/java/org/csource/fastdfs/StorageClient1.java
  42. 0 61
      src/main/java/org/csource/fastdfs/StorageServer.java
  43. 0 79
      src/main/java/org/csource/fastdfs/StructBase.java
  44. 0 226
      src/main/java/org/csource/fastdfs/StructGroupStat.java
  45. 0 934
      src/main/java/org/csource/fastdfs/StructStorageStat.java
  46. 0 990
      src/main/java/org/csource/fastdfs/TrackerClient.java
  47. 0 120
      src/main/java/org/csource/fastdfs/TrackerGroup.java
  48. 0 90
      src/main/java/org/csource/fastdfs/TrackerServer.java
  49. 0 27
      src/main/java/org/csource/fastdfs/UploadCallback.java
  50. 0 60
      src/main/java/org/csource/fastdfs/UploadStream.java
  51. 1 11
      src/main/resources/application-dev.yml
  52. 17 6
      src/main/resources/application.yml
  53. 2 2
      src/main/resources/mapper/job/ScheduleJobLogDao.xml
  54. 2 2
      src/main/resources/mapper/sys/SysConfigDao.xml
  55. 4 14
      src/main/resources/mapper/sys/SysLogDao.xml
  56. 9 1
      src/main/resources/static/js/common.js
  57. 31 20
      src/main/resources/static/js/index.js
  58. 22 2
      src/main/resources/static/js/modules/job/schedule.js
  59. 17 2
      src/main/resources/static/js/modules/sys/config.js
  60. 0 61
      src/main/resources/static/js/modules/sys/generator.js
  61. 2 1
      src/main/resources/static/js/modules/sys/log.js
  62. 17 1
      src/main/resources/static/js/modules/sys/menu.js
  63. 13 3
      src/main/resources/static/js/modules/sys/role.js
  64. 26 1
      src/main/resources/static/js/modules/sys/user.js
  65. 1305 0
      src/main/resources/static/libs/validator.js
  66. 23 0
      src/main/resources/static/libs/validator.min.js
  67. 1 0
      src/main/resources/static/swagger/css/print.css
  68. 1 0
      src/main/resources/static/swagger/css/reset.css
  69. 1 0
      src/main/resources/static/swagger/css/screen.css
  70. 1 0
      src/main/resources/static/swagger/css/style.css
  71. 0 0
      src/main/resources/static/swagger/css/typography.css
  72. BIN
      src/main/resources/static/swagger/favicon-16x16.png
  73. BIN
      src/main/resources/static/swagger/favicon-32x32.png
  74. BIN
      src/main/resources/static/swagger/fonts/DroidSans-Bold.ttf
  75. BIN
      src/main/resources/static/swagger/fonts/DroidSans.ttf
  76. BIN
      src/main/resources/static/swagger/images/collapse.gif
  77. BIN
      src/main/resources/static/swagger/images/expand.gif
  78. BIN
      src/main/resources/static/swagger/images/explorer_icons.png
  79. BIN
      src/main/resources/static/swagger/images/favicon-16x16.png
  80. BIN
      src/main/resources/static/swagger/images/favicon-32x32.png
  81. BIN
      src/main/resources/static/swagger/images/favicon.ico
  82. BIN
      src/main/resources/static/swagger/images/logo_small.png
  83. BIN
      src/main/resources/static/swagger/images/pet_store_api.png
  84. BIN
      src/main/resources/static/swagger/images/throbber.gif
  85. BIN
      src/main/resources/static/swagger/images/wordnik_api.png
  86. 107 0
      src/main/resources/static/swagger/index.html
  87. 1648 0
      src/main/resources/static/swagger/index.yaml
  88. 56 0
      src/main/resources/static/swagger/lang/en.js
  89. 39 0
      src/main/resources/static/swagger/lang/translator.js
  90. 56 0
      src/main/resources/static/swagger/lang/zh-cn.js
  91. 1 0
      src/main/resources/static/swagger/lib/backbone-min.js
  92. 1 0
      src/main/resources/static/swagger/lib/es5-shim.js
  93. 3 0
      src/main/resources/static/swagger/lib/handlebars-4.0.5.js
  94. 1 0
      src/main/resources/static/swagger/lib/highlight.9.1.0.pack.js
  95. 1 0
      src/main/resources/static/swagger/lib/highlight.9.1.0.pack_extended.js
  96. 3 0
      src/main/resources/static/swagger/lib/jquery-1.8.0.min.js
  97. 1 0
      src/main/resources/static/swagger/lib/jquery.ba-bbq.min.js
  98. 1 0
      src/main/resources/static/swagger/lib/jquery.slideto.min.js
  99. 1 0
      src/main/resources/static/swagger/lib/jquery.wiggle.min.js
  100. 0 0
      src/main/resources/static/swagger/lib/js-yaml.min.js

+ 6 - 0
README.md

@@ -77,6 +77,7 @@ renren-fast
 - Eclipse、IDEA运行RenrenApplication.java,则可启动项目
 - 项目访问路径:http://localhost
 - 账号密码:admin/admin
+- Swagger路径:http://localhost/swagger/index.html
 
 
  **项目演示**
@@ -84,6 +85,10 @@ renren-fast
 - 账号密码:admin/admin
 <br> 
 
+**接口文档效果图:**
+![输入图片说明](http://cdn.renren.io/img/6e8d7575fb8240d49b949dc0f02547bc "在这里输入图片标题")
+<br> <br> <br> 
+
 **演示效果图:**
 ![输入图片说明](http://cdn.renren.io/img/4f15a5513e4e4a00a07294e87c548982 "在这里输入图片标题")
 ![输入图片说明](http://cdn.renren.io/img/9b0c60dfe7ee48fb87bb933e31ebf36f "在这里输入图片标题")
@@ -92,3 +97,4 @@ renren-fast
 ![输入图片说明](http://cdn.renren.io/img/069045e6c6d24d88b6c2827a1b625da4 "在这里输入图片标题")
 ![输入图片说明](http://cdn.renren.io/img/5d4d6c1acd5c4455930dc5dc7d88ad82 "在这里输入图片标题")
 ![输入图片说明](http://cdn.renren.io/img/35dfe497ea7642028c7d6115a5a1c5e8 "在这里输入图片标题")
+

+ 3 - 2
doc/db.sql

@@ -80,6 +80,7 @@ CREATE TABLE `sys_log` (
   `operation` varchar(50) COMMENT '用户操作',
   `method` varchar(200) COMMENT '请求方法',
   `params` varchar(5000) COMMENT '请求参数',
+  `time` bigint NOT NULL COMMENT '执行时长(毫秒)',
   `ip` varchar(64) COMMENT 'IP地址',
   `create_date` datetime COMMENT '创建时间',
   PRIMARY KEY (`id`)
@@ -97,8 +98,8 @@ INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`,
 INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('17', '2', '修改', NULL, 'sys:user:update,sys:role:select', '2', NULL, '0');
 INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('18', '2', '删除', NULL, 'sys:user:delete', '2', NULL, '0');
 INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('19', '3', '查看', NULL, 'sys:role:list,sys:role:info', '2', NULL, '0');
-INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('20', '3', '新增', NULL, 'sys:role:save,sys:menu:perms', '2', NULL, '0');
-INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('21', '3', '修改', NULL, 'sys:role:update,sys:menu:perms', '2', NULL, '0');
+INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('20', '3', '新增', NULL, 'sys:role:save,sys:menu:list', '2', NULL, '0');
+INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('21', '3', '修改', NULL, 'sys:role:update,sys:menu:list', '2', NULL, '0');
 INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('22', '3', '删除', NULL, 'sys:role:delete', '2', NULL, '0');
 INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('23', '4', '查看', NULL, 'sys:menu:list,sys:menu:info', '2', NULL, '0');
 INSERT INTO `sys_menu` (`menu_id`, `parent_id`, `name`, `url`, `perms`, `type`, `icon`, `order_num`) VALUES ('24', '4', '新增', NULL, 'sys:menu:save,sys:menu:select', '2', NULL, '0');

+ 4 - 11
pom-war.xml

@@ -22,7 +22,6 @@
         <mysql.version>5.1.38</mysql.version>
         <druid.version>1.0.28</druid.version>
         <quartz.version>2.3.0</quartz.version>
-        <swagger.version>2.6.1</swagger.version>
         <commons.lang.version>2.6</commons.lang.version>
         <commons.fileupload.version>1.3.1</commons.fileupload.version>
         <commons.io.version>2.5</commons.io.version>
@@ -60,6 +59,10 @@
         </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-configuration-processor</artifactId>
             <optional>true</optional>
         </dependency>
@@ -95,16 +98,6 @@
             </exclusions>
         </dependency>
         <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger2</artifactId>
-            <version>${swagger.version}</version>
-        </dependency>
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger-ui</artifactId>
-            <version>${swagger.version}</version>
-        </dependency>
-        <dependency>
             <groupId>commons-lang</groupId>
             <artifactId>commons-lang</artifactId>
             <version>${commons.lang.version}</version>

+ 10 - 17
pom.xml

@@ -22,7 +22,6 @@
 		<mysql.version>5.1.38</mysql.version>
 		<druid.version>1.0.28</druid.version>
 		<quartz.version>2.3.0</quartz.version>
-		<swagger.version>2.6.1</swagger.version>
 		<commons.lang.version>2.6</commons.lang.version>
 		<commons.fileupload.version>1.3.1</commons.fileupload.version>
 		<commons.io.version>2.5</commons.io.version>
@@ -35,11 +34,11 @@
 		<qcloud.cos.version>4.4</qcloud.cos.version>
 
 		<!--wagon plugin 配置-->
-		<service-path>deploy_path</service-path>
-		<pack-name>full_jar_name</pack-name>
-		<remote-addr>remote_host_ip</remote-addr>
-		<remote-username>remote_host_username</remote-username>
-		<remote-passwd>remote_host_password</remote-passwd>
+		<service-path>/work/renren</service-path>
+		<pack-name>${artifactId}-${version}.jar</pack-name>
+		<remote-addr>192.168.1.10:22</remote-addr>
+		<remote-username>root</remote-username>
+		<remote-passwd>123456</remote-passwd>
 	</properties>
 
 	<dependencies>
@@ -62,6 +61,10 @@
 		</dependency>
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-data-redis</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-configuration-processor</artifactId>
 			<optional>true</optional>
 		</dependency>
@@ -97,16 +100,6 @@
 			</exclusions>
 		</dependency>
 		<dependency>
-			<groupId>io.springfox</groupId>
-			<artifactId>springfox-swagger2</artifactId>
-			<version>${swagger.version}</version>
-		</dependency>
-		<dependency>
-			<groupId>io.springfox</groupId>
-			<artifactId>springfox-swagger-ui</artifactId>
-			<version>${swagger.version}</version>
-		</dependency>
-		<dependency>
 			<groupId>commons-lang</groupId>
 			<artifactId>commons-lang</artifactId>
 			<version>${commons.lang.version}</version>
@@ -197,7 +190,7 @@
 						<command>pkill -f ${pack-name}</command>
 						<command>rm -f ${service-path}/renren.log</command>
 						<!-- Restart jar package,write result into renren.log -->
-						<command><![CDATA[nohup java -jar ${service-path}/${pack-name} > ${service-path}/renren.log 2>&1 & ]]></command>
+						<command><![CDATA[nohup java -jar ${service-path}/${pack-name} --spring.profiles.active=test > ${service-path}/renren.log 2>&1 & ]]></command>
 						<command><![CDATA[netstat -nptl]]></command>
 						<command><![CDATA[ps -ef | grep java | grep -v grep]]></command>
 					</commands>

+ 40 - 0
src/main/java/io/renren/common/aspect/RedisAspect.java

@@ -0,0 +1,40 @@
+package io.renren.common.aspect;
+
+import io.renren.common.exception.RRException;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Redis切面处理类
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2017-07-17 23:30
+ */
+@Aspect
+@Configuration
+public class RedisAspect {
+    private Logger logger = LoggerFactory.getLogger(getClass());
+    //是否开启redis缓存  true开启   false关闭
+    @Value("${spring.redis.open: #{false}}")
+    private boolean open;
+
+    @Around("execution(* io.renren.common.utils.RedisUtils.*(..))")
+    public Object around(ProceedingJoinPoint point) throws Throwable {
+        Object result = null;
+        if(open){
+            try{
+                result = point.proceed();
+            }catch (Exception e){
+                logger.error("redis error", e);
+                throw new RRException("Redis服务异常");
+            }
+        }
+        return result;
+    }
+}

+ 36 - 17
src/main/java/io/renren/common/aspect/SysLogAspect.java

@@ -1,16 +1,16 @@
 package io.renren.common.aspect;
 
 import com.google.gson.Gson;
+import io.renren.common.annotation.SysLog;
+import io.renren.common.utils.HttpContextUtils;
+import io.renren.common.utils.IPUtils;
 import io.renren.modules.sys.entity.SysLogEntity;
 import io.renren.modules.sys.entity.SysUserEntity;
 import io.renren.modules.sys.service.SysLogService;
-import io.renren.common.utils.HttpContextUtils;
-import io.renren.common.utils.IPUtils;
-import io.renren.common.annotation.SysLog;
 import org.apache.shiro.SecurityUtils;
-import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
 import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Before;
 import org.aspectj.lang.annotation.Pointcut;
 import org.aspectj.lang.reflect.MethodSignature;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -38,41 +38,60 @@ public class SysLogAspect {
 	public void logPointCut() { 
 		
 	}
-	
-	@Before("logPointCut()")
-	public void saveSysLog(JoinPoint joinPoint) {
+
+	@Around("logPointCut()")
+	public Object around(ProceedingJoinPoint point) throws Throwable {
+		long beginTime = System.currentTimeMillis();
+		//执行方法
+		Object result = point.proceed();
+		//执行时长(毫秒)
+		long time = System.currentTimeMillis() - beginTime;
+
+		//保存日志
+		saveSysLog(point, time);
+
+		return result;
+	}
+
+	private void saveSysLog(ProceedingJoinPoint joinPoint, long time) {
 		MethodSignature signature = (MethodSignature) joinPoint.getSignature();
 		Method method = signature.getMethod();
-		
+
 		SysLogEntity sysLog = new SysLogEntity();
 		SysLog syslog = method.getAnnotation(SysLog.class);
 		if(syslog != null){
-			//注解上的描述 
+			//注解上的描述
 			sysLog.setOperation(syslog.value());
 		}
-		
+
 		//请求的方法名
 		String className = joinPoint.getTarget().getClass().getName();
 		String methodName = signature.getName();
 		sysLog.setMethod(className + "." + methodName + "()");
-		
+
 		//请求的参数
 		Object[] args = joinPoint.getArgs();
-		String params = new Gson().toJson(args[0]);
-		sysLog.setParams(params);
-		
+		try{
+			String params = new Gson().toJson(args[0]);
+			sysLog.setParams(params);
+		}catch (Exception e){
+
+		}
+
 		//获取request
 		HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
 		//设置IP地址
 		sysLog.setIp(IPUtils.getIpAddr(request));
-		
+
 		//用户名
 		String username = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername();
 		sysLog.setUsername(username);
-		
+
+		sysLog.setTime(time);
 		sysLog.setCreateDate(new Date());
 		//保存系统日志
 		sysLogService.save(sysLog);
 	}
+
 	
 }

+ 15 - 0
src/main/java/io/renren/common/utils/RedisKeys.java

@@ -0,0 +1,15 @@
+package io.renren.common.utils;
+
+/**
+ * Redis所有Keys
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2017-07-18 19:51
+ */
+public class RedisKeys {
+
+    public static String getSysConfigKey(String key){
+        return "sys:config:" + key;
+    }
+}

+ 93 - 0
src/main/java/io/renren/common/utils/RedisUtils.java

@@ -0,0 +1,93 @@
+package io.renren.common.utils;
+
+import com.google.gson.Gson;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.*;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Redis工具类
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2017-07-17 21:12
+ */
+@Component
+public class RedisUtils {
+    @Autowired
+    private RedisTemplate<String, Object> redisTemplate;
+    @Autowired
+    private ValueOperations<String, String> valueOperations;
+    @Autowired
+    private HashOperations<String, String, Object> hashOperations;
+    @Autowired
+    private ListOperations<String, Object> listOperations;
+    @Autowired
+    private SetOperations<String, Object> setOperations;
+    @Autowired
+    private ZSetOperations<String, Object> zSetOperations;
+    /**  默认过期时长,单位:秒 */
+    public final static long DEFAULT_EXPIRE = 60 * 60 * 24;
+    /**  不设置过期时长 */
+    public final static long NOT_EXPIRE = -1;
+    private final static Gson gson = new Gson();
+
+    public void set(String key, Object value, long expire){
+        valueOperations.set(key, toJson(value));
+        if(expire != NOT_EXPIRE){
+            redisTemplate.expire(key, expire, TimeUnit.SECONDS);
+        }
+    }
+
+    public void set(String key, Object value){
+        set(key, value, DEFAULT_EXPIRE);
+    }
+
+    public <T> T get(String key, Class<T> clazz, long expire) {
+        String value = valueOperations.get(key);
+        if(expire != NOT_EXPIRE){
+            redisTemplate.expire(key, expire, TimeUnit.SECONDS);
+        }
+        return value == null ? null : fromJson(value, clazz);
+    }
+
+    public <T> T get(String key, Class<T> clazz) {
+        return get(key, clazz, NOT_EXPIRE);
+    }
+
+    public String get(String key, long expire) {
+        String value = valueOperations.get(key);
+        if(expire != NOT_EXPIRE){
+            redisTemplate.expire(key, expire, TimeUnit.SECONDS);
+        }
+        return value;
+    }
+
+    public String get(String key) {
+        return get(key, NOT_EXPIRE);
+    }
+
+    public void delete(String key) {
+        redisTemplate.delete(key);
+    }
+
+    /**
+     * Object转成JSON数据
+     */
+    private String toJson(Object object){
+        if(object instanceof Integer || object instanceof Long || object instanceof Float ||
+                object instanceof Double || object instanceof Boolean || object instanceof String){
+            return String.valueOf(object);
+        }
+        return gson.toJson(object);
+    }
+
+    /**
+     * JSON数据,转成Object
+     */
+    private <T> T fromJson(String json, Class<T> clazz){
+        return gson.fromJson(json, clazz);
+    }
+}

+ 5 - 2
src/main/java/io/renren/common/validator/ValidatorUtils.java

@@ -33,8 +33,11 @@ public class ValidatorUtils {
             throws RRException {
         Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);
         if (!constraintViolations.isEmpty()) {
-        	ConstraintViolation<Object> constraint = (ConstraintViolation<Object>)constraintViolations.iterator().next();
-            throw new RRException(constraint.getMessage());
+            StringBuilder msg = new StringBuilder();
+            for(ConstraintViolation<Object> constraint:  constraintViolations){
+                msg.append(constraint.getMessage()).append("<br>");
+            }
+            throw new RRException(msg.toString());
         }
     }
 }

+ 0 - 84
src/main/java/io/renren/config/FastDFSConfig.java

@@ -1,84 +0,0 @@
-package io.renren.config;
-
-
-import org.csource.common.MyException;
-import org.csource.fastdfs.ClientGlobal;
-import org.csource.fastdfs.TrackerClient;
-import org.csource.fastdfs.TrackerGroup;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-import java.net.InetSocketAddress;
-import java.util.List;
-
-/**
- * Created by Glenn on 2017/5/18 0018.
- */
-
-//@Configuration("FastDFSConfig")
-//@EnableCaching//启用缓存的意思
-public class FastDFSConfig {
-    /***
-     * Example
-     @Autowired
-     private TrackerClient client;
-
-     上传至FastDFS
-     StorageClient storageClient = new StorageClient(client.getConnection(), null);
-     String[] ret = storageClient.upload_file(fileContent,type.getPureSuffix(), null);
-     下载从FastDFS
-
-     StorageClient storageClient = new StorageClient(client.getConnection(), null);
-     FileInfo fi = storageClient.get_file_info(entity.getGroupName(), entity.getFileUri());
-     if (fi == null) {
-     throw new Exception("File information from FastDFS is null");
-     }
-     byte[] fileContent = storageClient.download_file(entity.getGroupName(), entity.getFileUri());
-     if (fileContent == null) {
-     throw new Exception("File entity from FastDFS is null");
-     }
-     * */
-
-
-    @Value("${fdfs.networkTimeout:#{null}}")
-    private Integer networkTimeout;
-    @Value("${fdfs.connectTimeout:#{null}}")
-    private Integer connectTimeout;
-    @Value("${fdfs.trackerServer:#{null}}")
-    List<String> trackerServer;
-    @Value("${fdfs.charset:#{null}}")
-    private String charset;
-    @Value("${fdfs.trackerHttpPort:#{null}}")
-    private Integer trackerHttpPort;
-    @Value("${fdfs.antiStealToken:#{null}}")
-    private Boolean antiStealToken;
-    @Value("${fdfs.secretKey:#{null}}")
-    private String secretKey;
-
-    @Bean
-    public TrackerClient getTrackerClient() throws MyException {
-        String[] parts;
-        ClientGlobal.setG_anti_steal_token(antiStealToken);
-        ClientGlobal.setG_charset(charset);
-        ClientGlobal.setG_connect_timeout(connectTimeout*1000);
-        ClientGlobal.setG_network_timeout(networkTimeout*1000);
-        ClientGlobal.setG_secret_key(secretKey);
-        InetSocketAddress[] tracker_servers = new InetSocketAddress[trackerServer.size()];
-        for (int i=0; i<trackerServer.size(); i++)
-        {
-            parts =trackerServer.get(i).split("\\:", 2);
-            if (parts.length != 2)
-            {
-                throw new MyException("the value of item \"tracker_server\" is invalid, the correct format is host:port");
-            }
-
-            tracker_servers[i] = new InetSocketAddress(parts[0].trim(), Integer.parseInt(parts[1].trim()));
-        }
-        ClientGlobal.setG_tracker_group(new TrackerGroup(tracker_servers));
-        ClientGlobal.setG_tracker_http_port(trackerHttpPort);
-        TrackerClient trackerClient = new TrackerClient();
-        return trackerClient;
-    }
-}

+ 57 - 0
src/main/java/io/renren/config/RedisConfig.java

@@ -0,0 +1,57 @@
+package io.renren.config;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.*;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+ * Redis配置
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2017-07-70 19:22
+ */
+@Configuration
+public class RedisConfig {
+    @Autowired
+    private RedisConnectionFactory factory;
+
+    @Bean
+    public RedisTemplate<String, Object> redisTemplate() {
+        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
+        redisTemplate.setKeySerializer(new StringRedisSerializer());
+        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
+        redisTemplate.setHashValueSerializer(new StringRedisSerializer());
+        redisTemplate.setValueSerializer(new StringRedisSerializer());
+        redisTemplate.setConnectionFactory(factory);
+        return redisTemplate;
+    }
+
+    @Bean
+    public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
+        return redisTemplate.opsForHash();
+    }
+
+    @Bean
+    public ValueOperations<String, String> valueOperations(RedisTemplate<String, String> redisTemplate) {
+        return redisTemplate.opsForValue();
+    }
+
+    @Bean
+    public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
+        return redisTemplate.opsForList();
+    }
+
+    @Bean
+    public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
+        return redisTemplate.opsForSet();
+    }
+
+    @Bean
+    public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
+        return redisTemplate.opsForZSet();
+    }
+}

+ 2 - 7
src/main/java/io/renren/config/ShiroConfig.java

@@ -32,7 +32,7 @@ public class ShiroConfig {
     public SessionManager sessionManager(){
         DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
         sessionManager.setSessionValidationSchedulerEnabled(true);
-        sessionManager.setSessionIdUrlRewritingEnabled(false);
+        //sessionManager.setSessionIdUrlRewritingEnabled(false);
         //sessionManager.setSessionIdCookieEnabled(false);
         return sessionManager;
     }
@@ -60,18 +60,13 @@ public class ShiroConfig {
         filterMap.put("/webjars/**", "anon");
         filterMap.put("/druid/**", "anon");
         filterMap.put("/api/**", "anon");
-
-        //swagger配置
-        filterMap.put("/swagger**", "anon");
-        filterMap.put("/v2/api-docs", "anon");
-        filterMap.put("/swagger-resources/configuration/ui", "anon");
-
         filterMap.put("/sys/login", "anon");
         filterMap.put("/**/*.css", "anon");
         filterMap.put("/**/*.js", "anon");
         filterMap.put("/**/*.html", "anon");
         filterMap.put("/fonts/**", "anon");
         filterMap.put("/plugins/**", "anon");
+        filterMap.put("/swagger/**", "anon");
         filterMap.put("/favicon.ico", "anon");
         filterMap.put("/captcha.jpg", "anon");
         filterMap.put("/", "anon");

+ 0 - 10
src/main/java/io/renren/modules/api/controller/ApiLoginController.java

@@ -6,10 +6,6 @@ import io.renren.common.validator.Assert;
 import io.renren.modules.api.annotation.AuthIgnore;
 import io.renren.modules.api.service.TokenService;
 import io.renren.modules.api.service.UserService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -26,7 +22,6 @@ import java.util.Map;
  */
 @RestController
 @RequestMapping("/api")
-@Api("登录接口")
 public class ApiLoginController {
     @Autowired
     private UserService userService;
@@ -38,11 +33,6 @@ public class ApiLoginController {
      */
     @AuthIgnore
     @PostMapping("login")
-    @ApiOperation(value = "登录",notes = "登录说明")
-    @ApiImplicitParams({
-        @ApiImplicitParam(paramType = "query", dataType="string", name = "mobile", value = "手机号", required = true),
-        @ApiImplicitParam(paramType = "query", dataType="string", name = "password", value = "密码", required = true)
-    })
     public R login(String mobile, String password){
         Assert.isBlank(mobile, "手机号不能为空");
         Assert.isBlank(password, "密码不能为空");

+ 0 - 10
src/main/java/io/renren/modules/api/controller/ApiRegisterController.java

@@ -5,10 +5,6 @@ import io.renren.common.utils.R;
 import io.renren.common.validator.Assert;
 import io.renren.modules.api.annotation.AuthIgnore;
 import io.renren.modules.api.service.UserService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiImplicitParams;
-import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -22,7 +18,6 @@ import org.springframework.web.bind.annotation.RestController;
  */
 @RestController
 @RequestMapping("/api")
-@Api("注册接口")
 public class ApiRegisterController {
     @Autowired
     private UserService userService;
@@ -32,11 +27,6 @@ public class ApiRegisterController {
      */
     @AuthIgnore
     @PostMapping("register")
-    @ApiOperation(value = "注册")
-    @ApiImplicitParams({
-            @ApiImplicitParam(paramType = "query", dataType="string", name = "mobile", value = "手机号", required = true),
-            @ApiImplicitParam(paramType = "query", dataType="string", name = "password", value = "密码", required = true)
-    })
     public R register(String mobile, String password){
         Assert.isBlank(mobile, "手机号不能为空");
         Assert.isBlank(password, "密码不能为空");

+ 10 - 10
src/main/java/io/renren/modules/api/controller/ApiTestController.java

@@ -4,13 +4,9 @@ package io.renren.modules.api.controller;
 import io.renren.common.utils.R;
 import io.renren.modules.api.annotation.AuthIgnore;
 import io.renren.modules.api.annotation.LoginUser;
+import io.renren.modules.api.entity.TokenEntity;
 import io.renren.modules.api.entity.UserEntity;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * API测试接口
@@ -21,15 +17,12 @@ import org.springframework.web.bind.annotation.RestController;
  */
 @RestController
 @RequestMapping("/api")
-@Api("测试接口")
 public class ApiTestController {
 
     /**
      * 获取用户信息
      */
     @GetMapping("userInfo")
-    @ApiOperation(value = "获取用户信息")
-    @ApiImplicitParam(paramType = "header", name = "token", value = "token", required = true)
     public R userInfo(@LoginUser UserEntity user){
         return R.ok().put("user", user);
     }
@@ -39,8 +32,15 @@ public class ApiTestController {
      */
     @AuthIgnore
     @GetMapping("notToken")
-    @ApiOperation(value = "忽略Token验证测试")
     public R notToken(){
         return R.ok().put("msg", "无需token也能访问。。。");
     }
+
+    /**
+     * 接收JSON数据
+     */
+    @PostMapping("jsonData")
+    public R jsonData(@LoginUser UserEntity user, @RequestBody TokenEntity token){
+        return R.ok().put("user", user).put("token", token);
+    }
 }

+ 1 - 1
src/main/java/io/renren/modules/job/entity/ScheduleJobEntity.java

@@ -49,7 +49,7 @@ public class ScheduleJobEntity implements Serializable {
 	private String cronExpression;
 
 	/**
-	 * 任务状态
+	 * 任务状态  0:正常  1:暂停
 	 */
 	private Integer status;
 

+ 1 - 1
src/main/java/io/renren/modules/sys/controller/SysConfigController.java

@@ -15,7 +15,7 @@ import java.util.List;
 import java.util.Map;
 
 /**
- * 系统配置信息
+ * 系统参数信息
  * 
  * @author chenshun
  * @email sunlightcs@gmail.com

+ 10 - 2
src/main/java/io/renren/modules/sys/controller/SysLoginController.java

@@ -30,7 +30,7 @@ import java.util.Map;
  * @date 2016年11月10日 下午1:15:31
  */
 @RestController
-public class SysLoginController {
+public class SysLoginController extends AbstractController {
 	@Autowired
 	private Producer producer;
 	@Autowired
@@ -38,7 +38,6 @@ public class SysLoginController {
 	@Autowired
 	private SysUserTokenService sysUserTokenService;
 
-
 	@RequestMapping("captcha.jpg")
 	public void captcha(HttpServletResponse response)throws ServletException, IOException {
 		response.setHeader("Cache-Control", "no-store, no-cache");
@@ -83,5 +82,14 @@ public class SysLoginController {
 		R r = sysUserTokenService.createToken(user.getUserId());
 		return r;
 	}
+
+	/**
+	 * 退出
+	 */
+	@RequestMapping(value = "/sys/logout", method = RequestMethod.POST)
+	public R logout() {
+		sysUserTokenService.logout(getUserId());
+		return R.ok();
+	}
 	
 }

+ 10 - 30
src/main/java/io/renren/modules/sys/controller/SysMenuController.java

@@ -2,7 +2,6 @@ package io.renren.modules.sys.controller;
 
 import io.renren.common.annotation.SysLog;
 import io.renren.common.exception.RRException;
-import io.renren.common.utils.Constant;
 import io.renren.common.utils.Constant.MenuType;
 import io.renren.common.utils.R;
 import io.renren.modules.sys.entity.SysMenuEntity;
@@ -34,6 +33,16 @@ public class SysMenuController extends AbstractController {
 	private SysMenuService sysMenuService;
 	@Autowired
 	private ShiroService shiroService;
+
+	/**
+	 * 导航菜单
+	 */
+	@RequestMapping("/nav")
+	public R nav(){
+		List<SysMenuEntity> menuList = sysMenuService.getUserMenuList(getUserId());
+		Set<String> permissions = shiroService.getUserPermissions(getUserId());
+		return R.ok().put("menuList", menuList).put("permissions", permissions);
+	}
 	
 	/**
 	 * 所有菜单列表
@@ -67,25 +76,6 @@ public class SysMenuController extends AbstractController {
 	}
 	
 	/**
-	 * 角色授权菜单
-	 */
-	@RequestMapping("/perms")
-	@RequiresPermissions("sys:menu:perms")
-	public R perms(){
-		//查询列表数据
-		List<SysMenuEntity> menuList = null;
-		
-		//只有超级管理员,才能查看所有管理员列表
-		if(getUserId() == Constant.SUPER_ADMIN){
-			menuList = sysMenuService.queryList(new HashMap<String, Object>());
-		}else{
-			menuList = sysMenuService.queryUserList(getUserId());
-		}
-		
-		return R.ok().put("menuList", menuList);
-	}
-	
-	/**
 	 * 菜单信息
 	 */
 	@RequestMapping("/info/{menuId}")
@@ -148,16 +138,6 @@ public class SysMenuController extends AbstractController {
 	}
 	
 	/**
-	 * 用户菜单列表
-	 */
-	@RequestMapping("/user")
-	public R user(){
-		List<SysMenuEntity> menuList = sysMenuService.getUserMenuList(getUserId());
-		Set<String> permissions = shiroService.getUserPermissions(getUserId());
-		return R.ok().put("menuList", menuList).put("permissions", permissions);
-	}
-	
-	/**
 	 * 验证参数是否正确
 	 */
 	private void verifyForm(SysMenuEntity menu){

+ 1 - 1
src/main/java/io/renren/modules/sys/dao/SysConfigDao.java

@@ -17,7 +17,7 @@ public interface SysConfigDao extends BaseDao<SysConfigEntity> {
 	/**
 	 * 根据key,查询value
 	 */
-	String queryByKey(String paramKey);
+	SysConfigEntity queryByKey(String paramKey);
 	
 	/**
 	 * 根据key,更新value

+ 10 - 0
src/main/java/io/renren/modules/sys/entity/SysLogEntity.java

@@ -23,6 +23,8 @@ public class SysLogEntity implements Serializable {
 	private String method;
 	//请求参数
 	private String params;
+	//执行时长(毫秒)
+	private Long time;
 	//IP地址
 	private String ip;
 	//创建时间
@@ -112,4 +114,12 @@ public class SysLogEntity implements Serializable {
 	public Date getCreateDate() {
 		return createDate;
 	}
+
+	public Long getTime() {
+		return time;
+	}
+
+	public void setTime(Long time) {
+		this.time = time;
+	}
 }

+ 38 - 0
src/main/java/io/renren/modules/sys/redis/SysConfigRedis.java

@@ -0,0 +1,38 @@
+package io.renren.modules.sys.redis;
+
+import io.renren.common.utils.RedisKeys;
+import io.renren.common.utils.RedisUtils;
+import io.renren.modules.sys.entity.SysConfigEntity;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 系统配置Redis
+ *
+ * @author chenshun
+ * @email sunlightcs@gmail.com
+ * @date 2017/7/18 21:08
+ */
+@Component
+public class SysConfigRedis {
+    @Autowired
+    private RedisUtils redisUtils;
+
+    public void saveOrUpdate(SysConfigEntity config) {
+        if(config == null){
+            return ;
+        }
+        String key = RedisKeys.getSysConfigKey(config.getKey());
+        redisUtils.set(key, config);
+    }
+
+    public void delete(String configKey) {
+        String key = RedisKeys.getSysConfigKey(configKey);
+        redisUtils.delete(key);
+    }
+
+    public SysConfigEntity get(String configKey){
+        String key = RedisKeys.getSysConfigKey(configKey);
+        return redisUtils.get(key, SysConfigEntity.class);
+    }
+}

+ 1 - 2
src/main/java/io/renren/modules/sys/service/SysConfigService.java

@@ -49,9 +49,8 @@ public interface SysConfigService {
 	 * 根据key,获取配置的value值
 	 * 
 	 * @param key           key
-	 * @param defaultValue  缺省值
 	 */
-	public String getValue(String key, String defaultValue);
+	public String getValue(String key);
 	
 	/**
 	 * 根据key,获取value的Object对象

+ 1 - 3
src/main/java/io/renren/modules/sys/service/SysLogService.java

@@ -21,9 +21,7 @@ public interface SysLogService {
 	int queryTotal(Map<String, Object> map);
 	
 	void save(SysLogEntity sysLog);
-	
-	void update(SysLogEntity sysLog);
-	
+
 	void delete(Long id);
 	
 	void deleteBatch(Long[] ids);

+ 6 - 2
src/main/java/io/renren/modules/sys/service/SysUserTokenService.java

@@ -14,8 +14,6 @@ public interface SysUserTokenService {
 
 	SysUserTokenEntity queryByUserId(Long userId);
 
-	SysUserTokenEntity queryByToken(String token);
-	
 	void save(SysUserTokenEntity token);
 	
 	void update(SysUserTokenEntity token);
@@ -26,4 +24,10 @@ public interface SysUserTokenService {
 	 */
 	R createToken(long userId);
 
+	/**
+	 * 退出,修改token值
+	 * @param userId  用户ID
+	 */
+	void logout(long userId);
+
 }

+ 23 - 7
src/main/java/io/renren/modules/sys/service/impl/SysConfigServiceImpl.java

@@ -1,10 +1,11 @@
 package io.renren.modules.sys.service.impl;
 
 import com.google.gson.Gson;
+import io.renren.common.exception.RRException;
 import io.renren.modules.sys.dao.SysConfigDao;
 import io.renren.modules.sys.entity.SysConfigEntity;
+import io.renren.modules.sys.redis.SysConfigRedis;
 import io.renren.modules.sys.service.SysConfigService;
-import io.renren.common.exception.RRException;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -17,26 +18,39 @@ import java.util.Map;
 public class SysConfigServiceImpl implements SysConfigService {
 	@Autowired
 	private SysConfigDao sysConfigDao;
+	@Autowired
+	private SysConfigRedis sysConfigRedis;
 	
 	@Override
 	@Transactional
 	public void save(SysConfigEntity config) {
 		sysConfigDao.save(config);
+		sysConfigRedis.saveOrUpdate(config);
 	}
 
 	@Override
+	@Transactional
 	public void update(SysConfigEntity config) {
 		sysConfigDao.update(config);
+		sysConfigRedis.saveOrUpdate(config);
 	}
 
 	@Override
+	@Transactional
 	public void updateValueByKey(String key, String value) {
 		sysConfigDao.updateValueByKey(key, value);
+		sysConfigRedis.delete(key);
 	}
 
 	@Override
+	@Transactional
 	public void deleteBatch(Long[] ids) {
 		sysConfigDao.deleteBatch(ids);
+
+		for(Long id : ids){
+			SysConfigEntity config = queryObject(id);
+			sysConfigRedis.delete(config.getKey());
+		}
 	}
 
 	@Override
@@ -55,17 +69,19 @@ public class SysConfigServiceImpl implements SysConfigService {
 	}
 
 	@Override
-	public String getValue(String key, String defaultValue) {
-		String value = sysConfigDao.queryByKey(key);
-		if(StringUtils.isBlank(value)){
-			return defaultValue;
+	public String getValue(String key) {
+		SysConfigEntity config = sysConfigRedis.get(key);
+		if(config == null){
+			config = sysConfigDao.queryByKey(key);
+			sysConfigRedis.saveOrUpdate(config);
 		}
-		return value;
+
+		return config == null ? null : config.getValue();
 	}
 	
 	@Override
 	public <T> T getConfigObject(String key, Class<T> clazz) {
-		String value = getValue(key, null);
+		String value = getValue(key);
 		if(StringUtils.isNotBlank(value)){
 			return new Gson().fromJson(value, clazz);
 		}

+ 0 - 5
src/main/java/io/renren/modules/sys/service/impl/SysLogServiceImpl.java

@@ -37,11 +37,6 @@ public class SysLogServiceImpl implements SysLogService {
 	}
 	
 	@Override
-	public void update(SysLogEntity sysLog){
-		sysLogDao.update(sysLog);
-	}
-	
-	@Override
 	public void delete(Long id){
 		sysLogDao.delete(id);
 	}

+ 12 - 5
src/main/java/io/renren/modules/sys/service/impl/SysUserTokenServiceImpl.java

@@ -24,11 +24,6 @@ public class SysUserTokenServiceImpl implements SysUserTokenService {
 	}
 
 	@Override
-	public SysUserTokenEntity queryByToken(String token) {
-		return sysUserTokenDao.queryByToken(token);
-	}
-
-	@Override
 	public void save(SysUserTokenEntity token){
 		sysUserTokenDao.save(token);
 	}
@@ -72,4 +67,16 @@ public class SysUserTokenServiceImpl implements SysUserTokenService {
 
 		return r;
 	}
+
+	@Override
+	public void logout(long userId) {
+		//生成一个token
+		String token = TokenGenerator.generateValue();
+
+		//修改token
+		SysUserTokenEntity tokenEntity = new SysUserTokenEntity();
+		tokenEntity.setUserId(userId);
+		tokenEntity.setToken(token);
+		update(tokenEntity);
+	}
 }

+ 0 - 472
src/main/java/org/csource/common/Base64.java

@@ -1,472 +0,0 @@
-package org.csource.common;
-
-import java.io.IOException;
-
-/**
- * Freeware from:
- * Roedy Green
- * Canadian Mind Products
- * #327 - 964 Heywood Avenue
- * Victoria, BC Canada V8V 2Y5
- * tel:(250) 361-9093
- * mailto:roedy@mindprod.com
- */
-
-/**
- * Encode arbitrary binary into printable ASCII using BASE64 encoding.
- * very loosely based on the Base64 Reader by
- * Dr. Mark Thornton
- * Optrak Distribution Software Ltd.
- * http://www.optrak.co.uk
- * and Kevin Kelley's  http://www.ruralnet.net/~kelley/java/Base64.java
- *
- * Base64 is a way of encoding 8-bit characters using only ASCII printable
- * characters similar to UUENCODE.  UUENCODE includes a filename where BASE64 does not.
- * The spec is described in RFC 2045.  Base64 is a scheme where
- * 3 bytes are concatenated, then split to form 4 groups of 6-bits each; and
- * each 6-bits gets translated to an encoded printable ASCII character, via a
- * table lookup.  An encoded string is therefore longer than the original by
- * about 1/3.  The "=" character is used to pad the end.  Base64 is used,
- * among other things, to encode the user:password string in an
- * Authorization: header for HTTP.  Don't confuse Base64 with
- * x-www-form-urlencoded which is handled by
- * Java.net.URLEncoder.encode/decode
- * If you don't like this code, there is another implementation at http://www.ruffboy.com/download.htm
- * Sun has an undocumented method called sun.misc.Base64Encoder.encode.
- * You could use hex, simpler to code, but not as compact.
- *
- * If you wanted to encode a giant file, you could do it in large chunks that
- * are even multiples of 3 bytes, except for the last chunk, and append the outputs.
- *
- * To encode a string, rather than binary data java.net.URLEncoder may be better. See
- * printable characters in the Java glossary for a discussion of the differences.
- *
- * version 1.4 2002 February 15  -- correct bugs with uneven line lengths,
- *                                  allow you to configure line separator.
- *                                  now need Base64 object and instance methods.
- *                                  new mailing address.
- * version 1.3 2000 September 12 -- fix problems with estimating output length in encode
- * version 1.2 2000 September 09 -- now handles decode as well.
- * version 1.1 1999 December 04 -- more symmetrical encoding algorithm.
- *                                 more accurate StringBuffer allocation size.
- * version 1.0 1999 December 03 -- posted in comp.lang.java.programmer.
- * Futures Streams or files.
- */
-
-public class Base64
-{
-
-   /**
-    * how we separate lines, e.g. \n, \r\n, \r etc.
-    */
-   private String lineSeparator = System.getProperty( "line.separator" );
-
-   /**
-    * max chars per line, excluding lineSeparator.  A multiple of 4.
-    */
-   private int lineLength = 72;
-
-   private char[] valueToChar = new char[64];
-
-   /**
-    * binary value encoded by a given letter of the alphabet 0..63
-    */
-   private int[] charToValue = new int[256];
-   
-   private int[] charToPad = new int[4];
-   
-   /* constructor */
-   public Base64()
-   {
-   	  this.init('+', '/', '=');
-   }
-   
-   /* constructor */
-   public Base64(char chPlus, char chSplash, char chPad, int lineLength)
-   {
-   	  this.init(chPlus, chSplash, chPad);
-   	  this.lineLength = lineLength;
-   }
-
-   public Base64(int lineLength)
-   {
-       this.lineLength = lineLength;
-   }
-
-   /* initialise defaultValueToChar and defaultCharToValue tables */
-   private void init(char chPlus, char chSplash, char chPad)
-   {
-   		int index = 0;
-      // build translate this.valueToChar table only once.
-      // 0..25 -> 'A'..'Z'
-      for ( int i='A'; i<='Z'; i++) {
-         this.valueToChar[index++] = (char)i;
-      }
-      
-      // 26..51 -> 'a'..'z'
-      for ( int i='a'; i<='z'; i++ ) {
-         this.valueToChar[index++] = (char)i;
-      }
-      
-      // 52..61 -> '0'..'9'
-      for ( int i='0'; i<='9'; i++) {
-         this.valueToChar[index++] = (char)i;
-      }
-      
-      this.valueToChar[index++] = chPlus;
-      this.valueToChar[index++] = chSplash;
-
-      // build translate defaultCharToValue table only once.
-      for ( int i=0; i<256; i++ )
-      {
-         this.charToValue[i] = IGNORE;  // default is to ignore
-      }
-
-      for ( int i=0; i<64; i++ )
-      {
-         this.charToValue[this.valueToChar[i]] = i;
-      }
-
-      this.charToValue[chPad] = PAD;
-      java.util.Arrays.fill(this.charToPad, chPad);
-   }
-   
-   /**
-    * Encode an arbitrary array of bytes as Base64 printable ASCII.
-    * It will be broken into lines of 72 chars each.  The last line is not
-    * terminated with a line separator.
-    * The output will always have an even multiple of data characters,
-    * exclusive of \n.  It is padded out with =.
-    */
-   public String encode(byte[] b) throws IOException
-      {
-      // Each group or partial group of 3 bytes becomes four chars
-      // covered quotient
-      int outputLength = ((b.length + 2) / 3) * 4;
-
-      // account for trailing newlines, on all but the very last line
-      if ( lineLength != 0 )
-         {
-          int lines =  ( outputLength + lineLength -1 ) / lineLength - 1;
-          if ( lines > 0 )
-            {
-             outputLength += lines  * lineSeparator.length();
-            }
-         }
-
-      // must be local for recursion to work.
-      StringBuffer sb = new StringBuffer( outputLength );
-
-      // must be local for recursion to work.
-      int linePos = 0;
-
-      // first deal with even multiples of 3 bytes.
-      int len = (b.length / 3) * 3;
-      int leftover = b.length - len;
-      for ( int i=0; i<len; i+=3 )
-         {
-         // Start a new line if next 4 chars won't fit on the current line
-         // We can't encapsulete the following code since the variable need to
-         // be local to this incarnation of encode.
-         linePos += 4;
-         if ( linePos > lineLength )
-            {
-            if ( lineLength != 0 )
-               {
-               sb.append(lineSeparator);
-               }
-            linePos = 4;
-            }
-
-         // get next three bytes in unsigned form lined up,
-         // in big-endian order
-         int combined = b[i+0] & 0xff;
-         combined <<= 8;
-         combined |= b[i+1] & 0xff;
-         combined <<= 8;
-         combined |= b[i+2] & 0xff;
-
-         // break those 24 bits into a 4 groups of 6 bits,
-         // working LSB to MSB.
-         int c3 = combined & 0x3f;
-         combined >>>= 6;
-         int c2 = combined & 0x3f;
-         combined >>>= 6;
-         int c1 = combined & 0x3f;
-         combined >>>= 6;
-         int c0 = combined & 0x3f;
-
-         // Translate into the equivalent alpha character
-         // emitting them in big-endian order.
-         sb.append( valueToChar[c0]);
-         sb.append( valueToChar[c1]);
-         sb.append( valueToChar[c2]);
-         sb.append( valueToChar[c3]);
-         }
-
-      // deal with leftover bytes
-      switch ( leftover )
-         {
-         case 0:
-         default:
-            // nothing to do
-            break;
-
-         case 1:
-            // One leftover byte generates xx==
-            // Start a new line if next 4 chars won't fit on the current line
-            linePos += 4;
-            if ( linePos > lineLength )
-               {
-
-               if ( lineLength != 0 )
-                  {
-                  sb.append(lineSeparator);
-                  }
-               linePos = 4;
-               }
-
-            // Handle this recursively with a faked complete triple.
-            // Throw away last two chars and replace with ==
-            sb.append(encode(new byte[] {b[len], 0, 0}
-                            ).substring(0,2));
-            sb.append("==");
-            break;
-
-         case 2:
-            // Two leftover bytes generates xxx=
-            // Start a new line if next 4 chars won't fit on the current line
-            linePos += 4;
-            if ( linePos > lineLength )
-               {
-               if ( lineLength != 0 )
-                  {
-                  sb.append(lineSeparator);
-                  }
-               linePos = 4;
-               }
-            // Handle this recursively with a faked complete triple.
-            // Throw away last char and replace with =
-            sb.append(encode(new byte[] {b[len], b[len+1], 0}
-                            ).substring(0,3));
-            sb.append("=");
-            break;
-
-         } // end switch;
-
-      if ( outputLength != sb.length() )
-         {
-         System.out.println("oops: minor program flaw: output length mis-estimated");
-         System.out.println("estimate:" + outputLength);
-         System.out.println("actual:" + sb.length());
-         }
-      return sb.toString();
-      }// end encode
-
-   /**
-    * decode a well-formed complete Base64 string back into an array of bytes.
-    * It must have an even multiple of 4 data characters (not counting \n),
-    * padded out with = as needed.
-    */
-   public byte[] decodeAuto( String s) {   	 
-   	 int nRemain = s.length() % 4;
-   	 if (nRemain == 0) {
-   	 	 return this.decode(s);
-   	 } else {
-   	   return this.decode(s + new String(this.charToPad, 0, 4 - nRemain));
-   	 }
-   }
-   
-   /**
-    * decode a well-formed complete Base64 string back into an array of bytes.
-    * It must have an even multiple of 4 data characters (not counting \n),
-    * padded out with = as needed.
-    */
-   public byte[] decode( String s)
-      {
-
-      // estimate worst case size of output array, no embedded newlines.
-      byte[] b = new byte[(s.length() / 4) * 3];
-
-      // tracks where we are in a cycle of 4 input chars.
-      int cycle = 0;
-
-      // where we combine 4 groups of 6 bits and take apart as 3 groups of 8.
-      int combined = 0;
-
-      // how many bytes we have prepared.
-      int j = 0;
-      // will be an even multiple of 4 chars, plus some embedded \n
-      int len = s.length();
-      int dummies = 0;
-      for ( int i=0; i<len; i++ )
-         {
-
-         int c = s.charAt(i);
-         int value  = (c <= 255) ? charToValue[c] : IGNORE;
-         // there are two magic values PAD (=) and IGNORE.
-         switch ( value )
-            {
-            case IGNORE:
-               // e.g. \n, just ignore it.
-               break;
-
-            case PAD:
-               value = 0;
-               dummies++;
-               // fallthrough
-            default:
-               /* regular value character */
-               switch ( cycle )
-                  {
-                  case 0:
-                     combined = value;
-                     cycle = 1;
-                     break;
-
-                  case 1:
-                     combined <<= 6;
-                     combined |= value;
-                     cycle = 2;
-                     break;
-
-                  case 2:
-                     combined <<= 6;
-                     combined |= value;
-                     cycle = 3;
-                     break;
-
-                  case 3:
-                     combined <<= 6;
-                     combined |= value;
-                     // we have just completed a cycle of 4 chars.
-                     // the four 6-bit values are in combined in big-endian order
-                     // peel them off 8 bits at a time working lsb to msb
-                     // to get our original 3 8-bit bytes back
-
-                     b[j+2] = (byte)combined;
-                     combined >>>= 8;
-                     b[j+1] = (byte)combined;
-                     combined >>>= 8;
-                     b[j] = (byte)combined;
-                     j += 3;
-                     cycle = 0;
-                     break;
-                  }
-               break;
-            }
-         } // end for
-      if ( cycle != 0 )
-         {
-         throw new ArrayIndexOutOfBoundsException ("Input to decode not an even multiple of 4 characters; pad with =.");
-         }
-      j -= dummies;
-      if ( b.length != j )
-         {
-         byte[] b2 = new byte[j];
-         System.arraycopy(b, 0, b2, 0, j);
-         b = b2;
-         }
-      return b;
-
-      }// end decode
-
-   /**
-    * determines how long the lines are that are generated by encode.
-    * Ignored by decode.
-    * @param length 0 means no newlines inserted. Must be a multiple of 4.
-    */
-   public void setLineLength(int length)
-      {
-      this.lineLength = (length/4) * 4;
-      }
-
-   /**
-    * How lines are separated.
-    * Ignored by decode.
-    * @param lineSeparator may be "" but not null.
-    * Usually contains only a combination of chars \n and \r.
-    * Could be any chars not in set A-Z a-z 0-9 + /.
-    */
-   public  void setLineSeparator(String lineSeparator)
-      {
-      this.lineSeparator = lineSeparator;
-      }
-
-   /**
-    * Marker value for chars we just ignore, e.g. \n \r high ascii
-    */
-   static final int IGNORE = -1;
-
-   /**
-    * Marker for = trailing pad
-    */
-   static final int PAD = -2;
-
-   /**
-    * used to disable test driver
-    */
-   private static final boolean debug = true;
-
-   /**
-    * debug display array
-    */
-   public static void show (byte[] b)
-   {
-      int count = 0;
-      int rows = 0;
-
-
-      for ( int i=0; i<b.length; i++ )
-      {
-         if(count == 8)
-         {
-            System.out.print("  ");
-         }
-         else if(count == 16)
-         {
-            System.out.println("");
-            count = 0;
-            continue;
-         }
-         System.out.print( Integer.toHexString(b[i] & 0xFF).toUpperCase() + " ");
-         count ++;
-
-      }
-      System.out.println();
-   }
-
-   /**
-    * debug display array
-    */
-   public static void display (byte[] b)
-      {
-      for ( int i=0; i<b.length; i++ )
-         {
-         System.out.print( (char)b[i]);
-         }
-      System.out.println();
-      }
-
-   public static void test()
-   {
-       try
-       {
-          Base64 b64 = new Base64();
-
-          //encode
-          //str64 = b64.encode(str.getBytes());
-          //System.out.println(str64);
-
-          String str64 = "CwUEFYoAAAADjQMC7ELJiY6w05267ELJiY6w05267ELJiY6w05267ELJiY6w05267ELJiY6w05267ELJiY6w05267ELJiY6w05267ELJiY6w05267ELJiY6w05267ELJiY6w05267ELJiY6w05267ELJiY6w05267ELJiY6w05267ELJiY6w05267EI=";
-          //decode
-          byte[] theBytes = b64.decode(str64);
-          show(theBytes);
-       }
-       catch(Exception e)
-       {
-          e.printStackTrace();
-       }
-   }
-} // end Base64
-

+ 0 - 190
src/main/java/org/csource/common/IniFileReader.java

@@ -1,190 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-**/
-
-package org.csource.common;
-
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Hashtable;
-
-/**
-* ini file reader / parser
-* @author Happy Fish / YuQing
-* @version Version 1.0
-*/
-public class IniFileReader
-{
-	private Hashtable paramTable;
-	private String conf_filename;
-	
-/**
-* @param conf_filename config filename
-*/
-	public IniFileReader(String conf_filename) throws FileNotFoundException, IOException
-	{
-		this.conf_filename = conf_filename;
-		loadFromFile(conf_filename);
-	}
-	
-/**
-* get the config filename
-* @return config filename
-*/
-	public String getConfFilename()
-	{
-		return this.conf_filename;
-	}
-	
-/**
-* get string value from config file
-* @param name item name in config file
-* @return string value
-*/
-	public String getStrValue(String name)
-	{
-		Object obj;
-		obj = this.paramTable.get(name);
-		if (obj == null)
-		{
-			return null;
-		}
-		
-		if (obj instanceof String)
-		{
-			return (String)obj;
-		}
-		
-		return (String)((ArrayList)obj).get(0);
-	}
-
-/**
-* get int value from config file
-* @param name item name in config file
-* @param default_value the default value
-* @return int value
-*/
-	public int getIntValue(String name, int default_value)
-	{
-		String szValue = this.getStrValue(name);
-		if (szValue == null)
-		{
-			return default_value;
-		}
-		
-		return Integer.parseInt(szValue);
-	}
-
-/**
-* get boolean value from config file
-* @param name item name in config file
-* @param default_value the default value
-* @return boolean value
-*/
-	public boolean getBoolValue(String name, boolean default_value)
-	{
-		String szValue = this.getStrValue(name);
-		if (szValue == null)
-		{
-			return default_value;
-		}
-		
-		return szValue.equalsIgnoreCase("yes") || szValue.equalsIgnoreCase("on") || 
-					 szValue.equalsIgnoreCase("true") || szValue.equals("1");
-	}
-	
-/**
-* get all values from config file
-* @param name item name in config file
-* @return string values (array)
-*/
-	public String[] getValues(String name)
-	{
-		Object obj;
-		String[] values;
-		
-		obj = this.paramTable.get(name);
-		if (obj == null)
-		{
-			return null;
-		}
-		
-		if (obj instanceof String)
-		{
-			values = new String[1];
-			values[0] = (String)obj;
-			return values;
-		}
-		
-		Object[] objs = ((ArrayList)obj).toArray();
-		values = new String[objs.length];
-		System.arraycopy(objs, 0, values, 0, objs.length);
-		return values;
-	}
-	
-	private void loadFromFile(String conf_filename) throws FileNotFoundException, IOException
-	{
-		FileReader fReader;
-		BufferedReader buffReader;
-		String line;
-		String[] parts;
-		String name;
-		String value;
-		Object obj;
-		ArrayList valueList;
-		
-	  fReader = new FileReader(conf_filename);
-	  buffReader = new BufferedReader(fReader);
-	  this.paramTable = new Hashtable();
-	  
-	  try
-	  {
-	  	while ((line=buffReader.readLine()) != null)
-	  	{
-	  		line = line.trim();
-	  		if (line.length() == 0 || line.charAt(0) == '#')
-	  		{
-	  			continue;
-	  		}
-	  		
-	  		parts = line.split("=", 2);
-	  		if (parts.length != 2)
-	  		{
-	  			continue;
-	  		}
-	  	
-	  		name = parts[0].trim();
-	  		value = parts[1].trim();
-	  		
-	  		obj = this.paramTable.get(name);
-	  		if (obj == null)
-	  		{
-	  			this.paramTable.put(name, value);
-	  		}
-	  		else if (obj instanceof String)
-	  		{
-	  			valueList = new ArrayList();
-	  			valueList.add(obj);
-	  			valueList.add(value);
-	  			this.paramTable.put(name, valueList);
-	  		}
-	  		else
-	  		{
-	  			valueList = (ArrayList)obj;
-	  			valueList.add(value);
-	  		}
-	  	}
-	  }
-	  finally
-	  {
-	  	fReader.close();
-	  }
-  }  
-}

+ 0 - 26
src/main/java/org/csource/common/MyException.java

@@ -1,26 +0,0 @@
-/*
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-*/
-
-package org.csource.common;
-
-/**
-* My Exception
-* @author Happy Fish / YuQing
-* @version Version 1.0
-*/
-public class MyException extends Exception
-{
-    public MyException()
-    {
-    }
-    
-    public MyException(String message)
-    {
-    		super(message);
-    }
-}

+ 0 - 55
src/main/java/org/csource/common/NameValuePair.java

@@ -1,55 +0,0 @@
-/*
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-*/
-
-package org.csource.common;
-
-/**
-* name(key) and value pair model
-* @author Happy Fish / YuQing
-* @version Version 1.0
-*/
-public class NameValuePair
-{
-    protected String name;
-    protected String value;
-
-    public NameValuePair()
-    {
-    }
-
-    public NameValuePair(String name)
-    {
-        this.name = name;
-    }
-
-    public NameValuePair(String name, String value)
-    {
-        this.name = name;
-        this.value = value;
-    }
-
-    public String getName()
-    {
-        return this.name;
-    }
-
-    public String getValue()
-    {
-        return this.value;
-    }
-
-    public void setName(String name)
-    {
-        this.name = name;
-    }
-
-    public void setValue(String value)
-    {
-        this.value = value;
-    }
-}

+ 0 - 201
src/main/java/org/csource/fastdfs/ClientGlobal.java

@@ -1,201 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-**/
-
-package org.csource.fastdfs;
-
-import org.csource.common.IniFileReader;
-import org.csource.common.MyException;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-
-/**
-* Global variables
-* @author Happy Fish / YuQing
-* @version Version 1.11
-*/
-public class ClientGlobal
-{
-	public static int g_connect_timeout; //millisecond
-	public static int g_network_timeout; //millisecond
-	public static String g_charset;
-	public static int g_tracker_http_port;
-	public static boolean g_anti_steal_token;  //if anti-steal token
-	public static String g_secret_key;   //generage token secret key
-	public static TrackerGroup g_tracker_group;
-	
-	public static final int DEFAULT_CONNECT_TIMEOUT = 5;  //second
-	public static final int DEFAULT_NETWORK_TIMEOUT = 30; //second
-	
-	private ClientGlobal()
-	{
-	}
-	
-/**
-* load global variables
-* @param conf_filename config filename
-*/
-	public static void init(String conf_filename) throws FileNotFoundException, IOException, MyException
-	{
-  		IniFileReader iniReader;
-  		String[] szTrackerServers;
-			String[] parts;
-			
-  		iniReader = new IniFileReader(conf_filename);
-
-			g_connect_timeout = iniReader.getIntValue("connect_timeout", DEFAULT_CONNECT_TIMEOUT);
-  		if (g_connect_timeout < 0)
-  		{
-  			g_connect_timeout = DEFAULT_CONNECT_TIMEOUT;
-  		}
-  		g_connect_timeout *= 1000; //millisecond
-  		
-  		g_network_timeout = iniReader.getIntValue("network_timeout", DEFAULT_NETWORK_TIMEOUT);
-  		if (g_network_timeout < 0)
-  		{
-  			g_network_timeout = DEFAULT_NETWORK_TIMEOUT;
-  		}
-  		g_network_timeout *= 1000; //millisecond
-
-  		g_charset = iniReader.getStrValue("charset");
-  		if (g_charset == null || g_charset.length() == 0)
-  		{
-  			g_charset = "ISO8859-1";
-  		}
-  		
-  		szTrackerServers = iniReader.getValues("tracker_server");
-  		if (szTrackerServers == null)
-  		{
-  			throw new MyException("item \"tracker_server\" in " + conf_filename + " not found");
-  		}
-  		
-  		InetSocketAddress[] tracker_servers = new InetSocketAddress[szTrackerServers.length];
-  		for (int i=0; i<szTrackerServers.length; i++)
-  		{
-  			parts = szTrackerServers[i].split("\\:", 2);
-  			if (parts.length != 2)
-  			{
-  				throw new MyException("the value of item \"tracker_server\" is invalid, the correct format is host:port");
-  			}
-  			
-  			tracker_servers[i] = new InetSocketAddress(parts[0].trim(), Integer.parseInt(parts[1].trim()));
-  		}
-  		g_tracker_group = new TrackerGroup(tracker_servers);
-  		
-  		g_tracker_http_port = iniReader.getIntValue("http.tracker_http_port", 80);
-  		g_anti_steal_token = iniReader.getBoolValue("http.anti_steal_token", false);
-  		if (g_anti_steal_token)
-  		{
-  			g_secret_key = iniReader.getStrValue("http.secret_key");
-  		}
-	}
-	
-/**
-* construct Socket object
-* @param ip_addr ip address or hostname
-* @param port port number
-* @return connected Socket object
-*/
-	public static Socket getSocket(String ip_addr, int port) throws IOException
-	{
-		Socket sock = new Socket();
-		sock.setSoTimeout(ClientGlobal.g_network_timeout);
-		sock.connect(new InetSocketAddress(ip_addr, port), ClientGlobal.g_connect_timeout);
-		return sock;
-	}
-	
-/**
-* construct Socket object
-* @param addr InetSocketAddress object, including ip address and port
-* @return connected Socket object
-*/
-	public static Socket getSocket(InetSocketAddress addr) throws IOException
-	{
-		Socket sock = new Socket();
-		sock.setSoTimeout(ClientGlobal.g_network_timeout);
-		sock.connect(addr, ClientGlobal.g_connect_timeout);
-		return sock;
-	}
-	
-	public static int getG_connect_timeout()
-	{
-		return g_connect_timeout;
-	}
-	
-	public static void setG_connect_timeout(int connect_timeout)
-	{
-		ClientGlobal.g_connect_timeout = connect_timeout;
-	}
-	
-	public static int getG_network_timeout()
-	{
-		return g_network_timeout;
-	}
-	
-	public static void setG_network_timeout(int network_timeout)
-	{
-		ClientGlobal.g_network_timeout = network_timeout;
-	}
-	
-	public static String getG_charset()
-	{
-		return g_charset;
-	}
-	
-	public static void setG_charset(String charset)
-	{
-		ClientGlobal.g_charset = charset;
-	}
-	
-	public static int getG_tracker_http_port()
-	{
-		return g_tracker_http_port;
-	}
-	
-	public static void setG_tracker_http_port(int tracker_http_port)
-	{
-		ClientGlobal.g_tracker_http_port = tracker_http_port;
-	}
-	
-	public static boolean getG_anti_steal_token()
-	{
-		return g_anti_steal_token;
-	}
-	
-	public static boolean isG_anti_steal_token()
-	{
-		return g_anti_steal_token;
-	}
-	
-	public static void setG_anti_steal_token(boolean anti_steal_token)
-	{
-		ClientGlobal.g_anti_steal_token = anti_steal_token;
-	}
-	
-	public static String getG_secret_key()
-	{
-		return g_secret_key;
-	}
-	
-	public static void setG_secret_key(String secret_key)
-	{
-		ClientGlobal.g_secret_key = secret_key;
-	}
-	
-	public static TrackerGroup getG_tracker_group()
-	{
-		return g_tracker_group;
-	}
-	
-	public static void setG_tracker_group(TrackerGroup tracker_group)
-	{
-		ClientGlobal.g_tracker_group = tracker_group;
-	}
-}

+ 0 - 26
src/main/java/org/csource/fastdfs/DownloadCallback.java

@@ -1,26 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-*/
-
-package org.csource.fastdfs;
-
-/**
-* Download file callback interface
-* @author Happy Fish / YuQing
-* @version Version 1.4
-*/
-public interface DownloadCallback
-{
-	/**
-	* recv file content callback function, may be called more than once when the file downloaded
-	* @param file_size file size
-	*	@param data data buff
-	* @param bytes data bytes
-	* @return 0 success, return none zero(errno) if fail
-	*/
-	public int recv(long file_size, byte[] data, int bytes);
-}

+ 0 - 49
src/main/java/org/csource/fastdfs/DownloadStream.java

@@ -1,49 +0,0 @@
-package org.csource.fastdfs;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
-* Download file by stream (download callback class)
-* @author  zhouzezhong & Happy Fish / YuQing
-* @version Version 1.11
-*/
-public class DownloadStream implements DownloadCallback
-{
-	private OutputStream out;
-	private long currentBytes = 0;
-	
-	public DownloadStream(OutputStream out)
-	{
-		super();
-		this.out = out;
-	}
-
-	/**
-	* recv file content callback function, may be called more than once when the file downloaded
-	* @param fileSize file size
-	*	@param data data buff
-	* @param bytes data bytes
-	* @return 0 success, return none zero(errno) if fail
-	*/
-	public int recv(long fileSize, byte[] data, int bytes)
-	{
-		try
-		{
-			out.write(data, 0, bytes);
-		}
-		catch(IOException ex)
-		{
-			ex.printStackTrace(); 
-			return -1;
-		}
-		
-		currentBytes +=	bytes;
-		if (this.currentBytes == fileSize)
-		{
-			this.currentBytes = 0;
-		}
-		
-		return 0;
-	}
-}

+ 0 - 125
src/main/java/org/csource/fastdfs/FileInfo.java

@@ -1,125 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-*/
-
-package org.csource.fastdfs;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
-* Server Info
-* @author Happy Fish / YuQing
-* @version Version 1.23
-*/
-public class FileInfo
-{
-	protected String source_ip_addr;
-	protected long file_size;
-	protected Date create_timestamp;
-	protected int crc32;
-
-/**
-* Constructor
-* @param file_size the file size
-* @param create_timestamp create timestamp in seconds
-* @param crc32 the crc32 signature
-* @param source_ip_addr the source storage ip address
-*/
-	public FileInfo(long file_size, int create_timestamp, int crc32, String source_ip_addr)
-	{
-		this.file_size = file_size;
-		this.create_timestamp = new Date(create_timestamp * 1000L);
-		this.crc32 = crc32;
-		this.source_ip_addr = source_ip_addr;
-	}
-
-/**
-* set the source ip address of the file uploaded to
-* @param source_ip_addr the source ip address
-*/
-	public void setSourceIpAddr(String source_ip_addr)
-	{
-		this.source_ip_addr = source_ip_addr;
-	}
-	
-/**
-* get the source ip address of the file uploaded to
-* @return the source ip address of the file uploaded to
-*/
-	public String getSourceIpAddr()
-	{
-		return this.source_ip_addr;
-	}
-	
-/**
-* set the file size
-* @param file_size the file size
-*/
-	public void setFileSize(long file_size)
-	{
-		this.file_size = file_size;
-	}
-	
-/**
-* get the file size
-* @return the file size
-*/
-	public long getFileSize()
-	{
-		return this.file_size;
-	}
-
-/**
-* set the create timestamp of the file
-* @param create_timestamp create timestamp in seconds
-*/
-	public void setCreateTimestamp(int create_timestamp)
-	{
-		this.create_timestamp = new Date(create_timestamp * 1000L);
-	}
-	
-/**
-* get the create timestamp of the file
-* @return the create timestamp of the file
-*/
-	public Date getCreateTimestamp()
-	{
-		return this.create_timestamp;
-	}
-
-/**
-* set the create timestamp of the file
-* @param crc32 the crc32 signature
-*/
-	public void setCrc32(int crc32)
-	{
-		this.crc32 = crc32;
-	}
-	
-/**
-* get the file CRC32 signature
-* @return the file CRC32 signature
-*/
-	public long getCrc32()
-	{
-		return this.crc32;
-	}
-	
-/**
-* to string
-* @return string
-*/
-	public String toString()
-	{
-		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-		return 	"source_ip_addr = " + this.source_ip_addr + ", " + 
-		        "file_size = " + this.file_size + ", " +
-		        "create_timestamp = " + df.format(this.create_timestamp) + ", " +
-		        "crc32 = " + this.crc32;
-	}
-}

+ 0 - 554
src/main/java/org/csource/fastdfs/ProtoCommon.java

@@ -1,554 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-**/
-
-package org.csource.fastdfs;
-
-import org.csource.common.MyException;
-import org.csource.common.NameValuePair;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.Socket;
-import java.security.NoSuchAlgorithmException;
-import java.util.Arrays;
-
-/**
-* protocol common functions
-* @author Happy Fish / YuQing
-* @version Version 1.18
-*/
-public class ProtoCommon
-{
-	/**
-	* receive package info
-	*/
-	public static class RecvPackageInfo
-	{
-		public byte errno;
-		public byte[] body;
-		
-		public RecvPackageInfo(byte errno, byte[] body)
-		{
-			this.errno = errno;
-			this.body = body;
-		}
-	}
-	
-	/**
-	* receive header info
-	*/
-	public static class RecvHeaderInfo
-	{
-		public byte errno;
-		public long body_len;
-		
-		public RecvHeaderInfo(byte errno, long body_len)
-		{
-			this.errno = errno;
-			this.body_len = body_len;
-		}
-	}
-	
-	public static final byte FDFS_PROTO_CMD_QUIT      = 82;
-	public static final byte TRACKER_PROTO_CMD_SERVER_LIST_GROUP     = 91;
-	public static final byte TRACKER_PROTO_CMD_SERVER_LIST_STORAGE   = 92;
-	public static final byte TRACKER_PROTO_CMD_SERVER_DELETE_STORAGE = 93;
-
-	public static final byte TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITHOUT_GROUP_ONE = 101;
-	public static final byte TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ONE = 102;
-	public static final byte TRACKER_PROTO_CMD_SERVICE_QUERY_UPDATE = 103;
-	public static final byte TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITH_GROUP_ONE = 104;
-	public static final byte TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ALL = 105;
-	public static final byte TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITHOUT_GROUP_ALL = 106;
-	public static final byte TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITH_GROUP_ALL = 107;
-	public static final byte TRACKER_PROTO_CMD_RESP = 100;
-	public static final byte FDFS_PROTO_CMD_ACTIVE_TEST = 111;
-	public static final byte STORAGE_PROTO_CMD_UPLOAD_FILE  = 11;
-	public static final byte STORAGE_PROTO_CMD_DELETE_FILE	= 12;
-	public static final byte STORAGE_PROTO_CMD_SET_METADATA	 = 13;
-	public static final byte STORAGE_PROTO_CMD_DOWNLOAD_FILE = 14;
-	public static final byte STORAGE_PROTO_CMD_GET_METADATA	 = 15;
-	public static final byte STORAGE_PROTO_CMD_UPLOAD_SLAVE_FILE   = 21;
-	public static final byte STORAGE_PROTO_CMD_QUERY_FILE_INFO     = 22;
-	public static final byte STORAGE_PROTO_CMD_UPLOAD_APPENDER_FILE= 23;  //create appender file
-	public static final byte STORAGE_PROTO_CMD_APPEND_FILE         = 24;  //append file
-	public static final byte STORAGE_PROTO_CMD_MODIFY_FILE         = 34;  //modify appender file
-	public static final byte STORAGE_PROTO_CMD_TRUNCATE_FILE       = 36;  //truncate appender file
-
-	public static final byte STORAGE_PROTO_CMD_RESP	 = TRACKER_PROTO_CMD_RESP;
-
-	public static final byte FDFS_STORAGE_STATUS_INIT        = 0;
-	public static final byte FDFS_STORAGE_STATUS_WAIT_SYNC   = 1;
-	public static final byte FDFS_STORAGE_STATUS_SYNCING     = 2;
-	public static final byte FDFS_STORAGE_STATUS_IP_CHANGED  = 3;
-	public static final byte FDFS_STORAGE_STATUS_DELETED     = 4;
-	public static final byte FDFS_STORAGE_STATUS_OFFLINE     = 5;
-	public static final byte FDFS_STORAGE_STATUS_ONLINE      = 6;
-	public static final byte FDFS_STORAGE_STATUS_ACTIVE      = 7;
-	public static final byte FDFS_STORAGE_STATUS_NONE        = 99;
-	
-	/**
-	* for overwrite all old metadata
-	*/
-	public static final byte STORAGE_SET_METADATA_FLAG_OVERWRITE = 'O';
-	
-	/**
-	* for replace, insert when the meta item not exist, otherwise update it
-	*/
-	public static final byte STORAGE_SET_METADATA_FLAG_MERGE = 'M';
-
-	public static final int FDFS_PROTO_PKG_LEN_SIZE	= 8;
-	public static final int FDFS_PROTO_CMD_SIZE		= 1;
-	public static final int FDFS_GROUP_NAME_MAX_LEN  = 16;
-	public static final int FDFS_IPADDR_SIZE	 = 16;
-	public static final int FDFS_DOMAIN_NAME_MAX_SIZE = 128;
-	public static final int FDFS_VERSION_SIZE = 6;
-	public static final int FDFS_STORAGE_ID_MAX_SIZE = 16;
-	
-	public static final String FDFS_RECORD_SEPERATOR	= "\u0001";
-	public static final String FDFS_FIELD_SEPERATOR	  = "\u0002";
-
-	public static final int TRACKER_QUERY_STORAGE_FETCH_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
-                        + FDFS_IPADDR_SIZE - 1 + FDFS_PROTO_PKG_LEN_SIZE;
-	public static final int TRACKER_QUERY_STORAGE_STORE_BODY_LEN = FDFS_GROUP_NAME_MAX_LEN
-                        + FDFS_IPADDR_SIZE + FDFS_PROTO_PKG_LEN_SIZE;
-
-	protected static final int PROTO_HEADER_CMD_INDEX	   = FDFS_PROTO_PKG_LEN_SIZE;
-	protected static final int PROTO_HEADER_STATUS_INDEX = FDFS_PROTO_PKG_LEN_SIZE+1;
-	
-	public static final byte FDFS_FILE_EXT_NAME_MAX_LEN  = 6;
-	public static final byte FDFS_FILE_PREFIX_MAX_LEN    = 16;
-	public static final byte FDFS_FILE_PATH_LEN          = 10;
-	public static final byte FDFS_FILENAME_BASE64_LENGTH = 27;
-	public static final byte FDFS_TRUNK_FILE_INFO_LEN    = 16;
-	
-	public static final byte ERR_NO_ENOENT    = 2;
-	public static final byte ERR_NO_EIO       = 5;
-	public static final byte ERR_NO_EBUSY     = 16;
-	public static final byte ERR_NO_EINVAL    = 22;
-	public static final byte ERR_NO_ENOSPC    = 28;
-	public static final byte ECONNREFUSED     = 61;
-	public static final byte ERR_NO_EALREADY  = 114;
-	
-	public static final long INFINITE_FILE_SIZE   = 256 * 1024L * 1024 * 1024 * 1024 * 1024L;
-	public static final long APPENDER_FILE_SIZE   = INFINITE_FILE_SIZE;
-	public static final long TRUNK_FILE_MARK_SIZE = 512 * 1024L * 1024 * 1024 * 1024 * 1024L;
-	public static final long NORMAL_LOGIC_FILENAME_LENGTH = FDFS_FILE_PATH_LEN + FDFS_FILENAME_BASE64_LENGTH + FDFS_FILE_EXT_NAME_MAX_LEN + 1;
-	public static final long TRUNK_LOGIC_FILENAME_LENGTH = NORMAL_LOGIC_FILENAME_LENGTH + FDFS_TRUNK_FILE_INFO_LEN;
-	
-	private ProtoCommon()
-	{
-	}
-
-	public static String getStorageStatusCaption(byte status)
-	{
-		switch(status)
-		{
-			case FDFS_STORAGE_STATUS_INIT:
-				return "INIT";
-			case FDFS_STORAGE_STATUS_WAIT_SYNC:
-				return "WAIT_SYNC";
-			case FDFS_STORAGE_STATUS_SYNCING:
-				return "SYNCING";
-			case FDFS_STORAGE_STATUS_IP_CHANGED:
-				return "IP_CHANGED";
-			case FDFS_STORAGE_STATUS_DELETED:
-				return "DELETED";
-			case FDFS_STORAGE_STATUS_OFFLINE:
-				return "OFFLINE";
-			case FDFS_STORAGE_STATUS_ONLINE:
-				return "ONLINE";
-			case FDFS_STORAGE_STATUS_ACTIVE:
-				return "ACTIVE";
-			case FDFS_STORAGE_STATUS_NONE:
-				return "NONE";
-			default:
-				return "UNKOWN";
-	}
-}
-
-/**
-* pack header by FastDFS transfer protocol
-* @param cmd which command to send
-* @param pkg_len package body length
-* @param errno status code, should be (byte)0
-* @return packed byte buffer
-*/
-	public static byte[] packHeader(byte cmd, long pkg_len, byte errno) throws UnsupportedEncodingException
-	{
-		byte[] header;
-		byte[] hex_len;
-		
-		header = new byte[FDFS_PROTO_PKG_LEN_SIZE + 2];
-		Arrays.fill(header, (byte)0);
-		
-		hex_len = ProtoCommon.long2buff(pkg_len);
-		System.arraycopy(hex_len, 0, header, 0, hex_len.length);
-		header[PROTO_HEADER_CMD_INDEX] = cmd;
-		header[PROTO_HEADER_STATUS_INDEX] = errno;
-		return header;
-	}
-
-/**
-* receive pack header
-* @param in input stream
-* @param expect_cmd expect response command
-* @param expect_body_len expect response package body length
-* @return RecvHeaderInfo: errno and pkg body length
-*/
-	public static RecvHeaderInfo recvHeader(InputStream in, byte expect_cmd, long expect_body_len) throws IOException
-	{
-		byte[] header;
-		int bytes;
-		long pkg_len;
-		
-		header = new byte[FDFS_PROTO_PKG_LEN_SIZE + 2];
-		
-		if ((bytes=in.read(header)) != header.length)
-		{
-			throw new IOException("recv package size " + bytes + " != " + header.length);
-		}
-		
-		if (header[PROTO_HEADER_CMD_INDEX] != expect_cmd)
-		{
-			throw new IOException("recv cmd: " + header[PROTO_HEADER_CMD_INDEX] + " is not correct, expect cmd: " + expect_cmd);
-		}
-		
-		if (header[PROTO_HEADER_STATUS_INDEX] != 0)
-		{
-			return new RecvHeaderInfo(header[PROTO_HEADER_STATUS_INDEX], 0);
-		}
-		
-		pkg_len = ProtoCommon.buff2long(header, 0);
-		if (pkg_len < 0)
-		{
-			throw new IOException("recv body length: " + pkg_len + " < 0!");
-		}
-		
-		if (expect_body_len >= 0 && pkg_len != expect_body_len)
-		{
-			throw new IOException("recv body length: " + pkg_len + " is not correct, expect length: " + expect_body_len);
-		}
-		
-		return new RecvHeaderInfo((byte)0, pkg_len);
-	}
-
-/**
-* receive whole pack
-* @param in input stream
-* @param expect_cmd expect response command
-* @param expect_body_len expect response package body length
-* @return RecvPackageInfo: errno and reponse body(byte buff)
-*/
-	public static RecvPackageInfo recvPackage(InputStream in, byte expect_cmd, long expect_body_len) throws IOException
-	{
-		RecvHeaderInfo header = recvHeader(in, expect_cmd, expect_body_len);
-		if (header.errno != 0)
-		{
-			return new RecvPackageInfo(header.errno, null);
-		}
-		
-		byte[] body = new byte[(int)header.body_len];
-		int totalBytes = 0;
-		int remainBytes = (int)header.body_len;
-		int bytes;
-		
-		while (totalBytes < header.body_len)
-		{
-			if ((bytes=in.read(body, totalBytes, remainBytes)) < 0)
-			{
-				break;
-			}
-			
-			totalBytes += bytes;
-			remainBytes -= bytes;
-		}
-		
-		if (totalBytes != header.body_len)
-		{
-			throw new IOException("recv package size " + totalBytes + " != " + header.body_len);
-		}
-		
-		return new RecvPackageInfo((byte)0, body);
-	}
-
-/**
-* split metadata to name value pair array
-* @param meta_buff metadata
-* @return name value pair array
-*/
-	public static NameValuePair[] split_metadata(String meta_buff)
-	{
-		return split_metadata(meta_buff, FDFS_RECORD_SEPERATOR, FDFS_FIELD_SEPERATOR);
-	}
-
-/**
-* split metadata to name value pair array
-* @param meta_buff metadata
-* @param recordSeperator record/row seperator
-* @param filedSeperator field/column seperator
-* @return name value pair array
-*/
-	public static NameValuePair[] split_metadata(String meta_buff,
-                                                 String  recordSeperator, String  filedSeperator)
-	{
-		String[] rows;
-		String[] cols;
-		NameValuePair[] meta_list;
-	
-		rows = meta_buff.split(recordSeperator);
-		meta_list = new NameValuePair[rows.length];
-		for (int i=0; i<rows.length; i++)
-		{
-			cols = rows[i].split(filedSeperator, 2);
-			meta_list[i] = new NameValuePair(cols[0]);
-			if (cols.length == 2)
-			{
-				meta_list[i].setValue(cols[1]);
-			}
-		}
-		
-		return meta_list;
-	}
-
-/**
-* pack metadata array to string
-* @param meta_list metadata array
-* @return packed metadata
-*/
-	public static String pack_metadata(NameValuePair[] meta_list)
-	{		
-		if (meta_list.length == 0)
-		{
-			return "";
-		}
-		
-		StringBuffer sb = new StringBuffer(32 * meta_list.length);
-		sb.append(meta_list[0].getName()).append(FDFS_FIELD_SEPERATOR).append(meta_list[0].getValue());
-		for (int i=1; i<meta_list.length; i++)
-		{
-			sb.append(FDFS_RECORD_SEPERATOR);
-			sb.append(meta_list[i].getName()).append(FDFS_FIELD_SEPERATOR).append(meta_list[i].getValue());
-		}
-	
-		return sb.toString();
-	}
-
-/**
-* send quit command to server and close socket
-* @param sock the Socket object
-*/
-	public static void closeSocket(Socket sock) throws IOException
-	{
-		byte[] header;
-		header = packHeader(FDFS_PROTO_CMD_QUIT, 0, (byte)0);
-		sock.getOutputStream().write(header);
-		sock.close();
-	}
-	
-/**
-* send ACTIVE_TEST command to server, test if network is ok and the server is alive
-* @param sock the Socket object
-*/
-	public static boolean activeTest(Socket sock) throws IOException
-	{
-		byte[] header;
-		header = packHeader(FDFS_PROTO_CMD_ACTIVE_TEST, 0, (byte)0);
-		sock.getOutputStream().write(header);
-		
-		RecvHeaderInfo headerInfo = recvHeader(sock.getInputStream(), TRACKER_PROTO_CMD_RESP, 0);
-		return headerInfo.errno == 0 ? true : false;
-	}
-	
-/**
-* long convert to buff (big-endian)
-* @param n long number
-* @return 8 bytes buff
-*/
-	public static byte[] long2buff(long n)
-	{
-		byte[] bs;
-		
-		bs = new byte[8];
-		bs[0] = (byte)((n >> 56) & 0xFF);
-		bs[1] = (byte)((n >> 48) & 0xFF);
-		bs[2] = (byte)((n >> 40) & 0xFF);
-		bs[3] = (byte)((n >> 32) & 0xFF);
-		bs[4] = (byte)((n >> 24) & 0xFF);
-		bs[5] = (byte)((n >> 16) & 0xFF);
-		bs[6] = (byte)((n >> 8) & 0xFF);
-		bs[7] = (byte)(n & 0xFF);
-		
-		return bs;
-	}
-	
-/**
-* buff convert to long
-* @param bs the buffer (big-endian)
-* @param offset the start position based 0
-* @return long number
-*/
-	public static long buff2long(byte[] bs, int offset)
-	{
-		return  (((long)(bs[offset] >= 0 ? bs[offset] : 256+bs[offset])) << 56) |
-		        (((long)(bs[offset+1] >= 0 ? bs[offset+1] : 256+bs[offset+1])) << 48) | 
-		        (((long)(bs[offset+2] >= 0 ? bs[offset+2] : 256+bs[offset+2])) << 40) | 
-		        (((long)(bs[offset+3] >= 0 ? bs[offset+3] : 256+bs[offset+3])) << 32) | 
-		        (((long)(bs[offset+4] >= 0 ? bs[offset+4] : 256+bs[offset+4])) << 24) | 
-		        (((long)(bs[offset+5] >= 0 ? bs[offset+5] : 256+bs[offset+5])) << 16) | 
-		        (((long)(bs[offset+6] >= 0 ? bs[offset+6] : 256+bs[offset+6])) <<  8) |
-		         ((long)(bs[offset+7] >= 0 ? bs[offset+7] : 256+bs[offset+7]));
-	}
-
-/**
-* buff convert to int
-* @param bs the buffer (big-endian)
-* @param offset the start position based 0
-* @return int number
-*/
-	public static int buff2int(byte[] bs, int offset)
-	{
-		return  (((int)(bs[offset] >= 0 ? bs[offset] : 256+bs[offset])) << 24) | 
-		        (((int)(bs[offset+1] >= 0 ? bs[offset+1] : 256+bs[offset+1])) << 16) | 
-		        (((int)(bs[offset+2] >= 0 ? bs[offset+2] : 256+bs[offset+2])) <<  8) |
-		         ((int)(bs[offset+3] >= 0 ? bs[offset+3] : 256+bs[offset+3]));
-	}
-	
-/**
-* buff convert to ip address
-* @param bs the buffer (big-endian)
-* @param offset the start position based 0
-* @return ip address
-*/
-	public static String getIpAddress(byte[] bs, int offset)
-	{
-		if (bs[0] == 0 || bs[3] == 0) //storage server ID
-		{
-			return "";
-		}
-		
-		int n;
-		StringBuilder sbResult = new StringBuilder(16);
-		for (int i=offset; i<offset+4; i++)
-		{
-			n = (bs[i] >= 0) ? bs[i] : 256 + bs[i];
-			if (sbResult.length() > 0)
-			{
-				sbResult.append(".");
-			}
-			sbResult.append(String.valueOf(n));
-		}
-		
-		return sbResult.toString();
-	}
-	
- /**
-* md5 function
-* @param source the input buffer
-* @return md5 string
-*/
-	public static String md5(byte[] source) throws NoSuchAlgorithmException
-	{
-  	char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',  'e', 'f'};
-    java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
-    md.update(source);
-    byte tmp[] = md.digest();
-    char str[] = new char[32];
-    int k = 0;
-    for (int i = 0; i < 16; i++)
-    {
-     str[k++] = hexDigits[tmp[i] >>> 4 & 0xf];
-     str[k++] = hexDigits[tmp[i] & 0xf];
-    }
-    
-  	return new String(str);
- }
- 
- /**
-* get token for file URL
-* @param remote_filename the filename return by FastDFS server
-* @param ts unix timestamp, unit: second
-* @param secret_key the secret key
-* @return token string
-*/
- public static String getToken(String remote_filename, int ts, String secret_key) throws UnsupportedEncodingException, NoSuchAlgorithmException, MyException
- {
- 	byte[] bsFilename = remote_filename.getBytes(ClientGlobal.g_charset);
- 	byte[] bsKey = secret_key.getBytes(ClientGlobal.g_charset);
- 	byte[] bsTimestamp = (new Integer(ts)).toString().getBytes(ClientGlobal.g_charset);
- 	
- 	byte[] buff = new byte[bsFilename.length + bsKey.length + bsTimestamp.length];
- 	System.arraycopy(bsFilename, 0, buff, 0, bsFilename.length);
- 	System.arraycopy(bsKey, 0, buff, bsFilename.length, bsKey.length);
- 	System.arraycopy(bsTimestamp, 0, buff, bsFilename.length + bsKey.length, bsTimestamp.length);
- 	
- 	return md5(buff);
- }
- 
- /**
-* generate slave filename
-* @param master_filename the master filename to generate the slave filename
-* @param prefix_name the prefix name to generate the slave filename
-* @param ext_name the extension name of slave filename, null for same as the master extension name
-* @return slave filename string
-*/
- public static String genSlaveFilename(String master_filename, 
-                String prefix_name, String ext_name) throws MyException
- {
-    String true_ext_name;
-    int dotIndex;
-
-    if (master_filename.length() < 28 + FDFS_FILE_EXT_NAME_MAX_LEN)
-    {
-            throw new MyException("master filename \"" + master_filename + "\" is invalid");
-    }
-
-    dotIndex = master_filename.indexOf('.', master_filename.length() - (FDFS_FILE_EXT_NAME_MAX_LEN + 1));
-    if (ext_name != null)
-    {
-	      if (ext_name.length() == 0)
-	      {
-	              true_ext_name = "";
-	      }
-	      else if (ext_name.charAt(0) == '.')
-	      {
-	              true_ext_name = ext_name;
-	      }
-	      else
-	      {
-	              true_ext_name = "." + ext_name;
-	      }
-    }
-		else
-    {
-	      if (dotIndex < 0)
-	      {
-	              true_ext_name = "";
-	      }
-	      else
-	      {
-	              true_ext_name = master_filename.substring(dotIndex);
-	      }
-    }
-
-    if (true_ext_name.length() == 0 && prefix_name.equals("-m"))
-    {
-        throw new MyException("prefix_name \"" + prefix_name + "\" is invalid");
-    }
-
-    if (dotIndex < 0)
-    {
-        return master_filename + prefix_name + true_ext_name;
-    }
-    else
-    {
-        return master_filename.substring(0, dotIndex) + prefix_name + true_ext_name;
-    }
-	}
-}

+ 0 - 52
src/main/java/org/csource/fastdfs/ProtoStructDecoder.java

@@ -1,52 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-*/
-
-package org.csource.fastdfs;
-
-import java.io.IOException;
-import java.lang.reflect.Array;
-
-/**
-* C struct body decoder
-* @author Happy Fish / YuQing
-* @version Version 1.17
-*/
-public class ProtoStructDecoder<T extends StructBase>
-{	
-/**
-* Constructor
-*/
-	public ProtoStructDecoder()
-	{
-	}
-	
-/**
-* decode byte buffer
-*/
-	public T[] decode(byte[] bs, Class<T> clazz, int fieldsTotalSize) throws Exception
-	{
-		if (bs.length % fieldsTotalSize != 0)
-		{
-			throw new IOException("byte array length: " + bs.length + " is invalid!");
-		}
-		
-		int count = bs.length / fieldsTotalSize;
-		int offset;
-		T[] results = (T[])Array.newInstance(clazz, count);
-		
-		offset = 0;
-		for (int i=0; i<results.length; i++)
-		{
-			results[i] = clazz.newInstance();
-			results[i].setFields(bs, offset);
-			offset += fieldsTotalSize;
-		}
-		
-		return results;
-	}
-}

+ 0 - 66
src/main/java/org/csource/fastdfs/ServerInfo.java

@@ -1,66 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-*/
-
-package org.csource.fastdfs;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-
-/**
-* Server Info
-* @author Happy Fish / YuQing
-* @version Version 1.7
-*/
-public class ServerInfo
-{
-	protected String ip_addr;
-	protected int port;
-	
-/**
-* Constructor
-* @param ip_addr address of the server
-* @param port the port of the server
-*/
-	public ServerInfo(String ip_addr, int port)
-	{
-		this.ip_addr = ip_addr;
-		this.port = port;
-	}
-	
-/**
-* return the ip address
-* @return the ip address
-*/
-	public String getIpAddr()
-	{
-		return this.ip_addr;
-	}
-	
-/**
-* return the port of the server
-* @return the port of the server
-*/
-	public int getPort()
-	{
-		return this.port;
-	}
-	
-/**
-* connect to server
-* @return connected Socket object
-*/
-	public Socket connect() throws IOException
-	{
-		Socket sock = new Socket();
-		sock.setReuseAddress(true);
-		sock.setSoTimeout(ClientGlobal.g_network_timeout);
-		sock.connect(new InetSocketAddress(this.ip_addr, this.port), ClientGlobal.g_connect_timeout);
-		return sock;
-	}
-}

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 0 - 2076
src/main/java/org/csource/fastdfs/StorageClient.java


+ 0 - 799
src/main/java/org/csource/fastdfs/StorageClient1.java

@@ -1,799 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-*/
-
-package org.csource.fastdfs;
-
-import org.csource.common.MyException;
-import org.csource.common.NameValuePair;
-
-import java.io.IOException;
-
-/**
-* Storage client for 1 field file id: combined group name and filename
-* @author Happy Fish / YuQing
-* @version Version 1.21
-*/
-public class StorageClient1 extends StorageClient
-{
-	public static final String SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR = "/";
-	
-/**
-* constructor
-*/
-	public StorageClient1()
-	{
-		super();
-	}
-	
-/**
-* constructor
-* @param trackerServer the tracker server, can be null
-* @param storageServer the storage server, can be null
-*/
-	public StorageClient1(TrackerServer trackerServer, StorageServer storageServer)
-	{
-		super(trackerServer, storageServer);
-	}
-
-	public static byte split_file_id(String file_id, String[] results)
-	{
-		int pos = file_id.indexOf(SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR);
-		if ((pos <= 0) || (pos == file_id.length() - 1))
-		{
-			return ProtoCommon.ERR_NO_EINVAL;
-		}
-		
-		results[0] = file_id.substring(0, pos); //group name
-		results[1] = file_id.substring(pos + 1); //file name
-		return 0;
-  }
-  	
-	/**
-	* upload file to storage server (by file name)
-	* @param local_filename local filename to upload
-	* @param file_ext_name file ext name, do not include dot(.), null to extract ext name from the local filename
-	* @param meta_list meta info array
-	* @return  file id(including group name and filename) if success, <br>
-	*         return null if fail
-	*/
-	public String upload_file1(String local_filename, String file_ext_name, 
-	       NameValuePair[] meta_list) throws IOException, MyException
-	{
-		String parts[] = this.upload_file(local_filename, file_ext_name, meta_list);
-		if (parts != null)
-		{
-			return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
-		}
-		else
-		{
-			return null;
-		}
-	}
-
-	/**
-	* upload file to storage server (by file name)
-	* @param group_name the group name to upload file to, can be empty
-	* @param local_filename local filename to upload
-	* @param file_ext_name file ext name, do not include dot(.), null to extract ext name from the local filename
-	* @param meta_list meta info array
-	* @return  file id(including group name and filename) if success, <br>
-	*         return null if fail
-	*/
-	public String upload_file1(String group_name, String local_filename, String file_ext_name, 
-	       NameValuePair[] meta_list) throws IOException, MyException
-	{
-		String parts[] = this.upload_file(group_name, local_filename, file_ext_name, meta_list);
-		if (parts != null)
-		{
-			return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
-		}
-		else
-		{
-			return null;
-		}
-	}
-	
-	/**
-	* upload file to storage server (by file buff)
-	* @param file_buff file content/buff
-	* @param file_ext_name file ext name, do not include dot(.)
-	*	@param meta_list meta info array
-	* @return  file id(including group name and filename) if success, <br>
-	*         return null if fail
-	*/
-	public String upload_file1(byte[] file_buff, String file_ext_name,	
-	       NameValuePair[] meta_list) throws IOException, MyException
-	{
-		String parts[] = this.upload_file(file_buff, file_ext_name, meta_list);
-		if (parts != null)
-		{
-			return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
-		}
-		else
-		{
-			return null;
-		}
-	}
-
-	/**
-	* upload file to storage server (by file buff)
-	* @param group_name the group name to upload file to, can be empty
-	* @param file_buff file content/buff
-	* @param file_ext_name file ext name, do not include dot(.)
-	*	@param meta_list meta info array
-	* @return  file id(including group name and filename) if success, <br>
-	*         return null if fail
-	*/
-	public String upload_file1(String group_name, byte[] file_buff, String file_ext_name,	
-	       NameValuePair[] meta_list) throws IOException, MyException
-	{
-		String parts[] = this.upload_file(group_name, file_buff, file_ext_name, meta_list);
-		if (parts != null)
-		{
-			return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
-		}
-		else
-		{
-			return null;
-		}
-	}
-
-	/**
-	* upload file to storage server (by callback)
-	* @param group_name the group name to upload file to, can be empty
-	* @param file_size the file size
-	* @param callback the write data callback object
-	* @param file_ext_name file ext name, do not include dot(.)
-	*	@param meta_list meta info array
-  * @return file id(including group name and filename) if success, <br>
-	*         return null if fail
-	*/
-	public String upload_file1(String group_name, long file_size, 
-	       UploadCallback callback, String file_ext_name, 
-	       NameValuePair[] meta_list) throws IOException, MyException
-	{
-		String parts[] = this.upload_file(group_name, file_size, callback, file_ext_name, meta_list);
-		if (parts != null)
-		{
-			return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
-		}
-		else
-		{
-			return null;
-		}
-	}
-
-	/**
-	* upload appender file to storage server (by file name)
-	* @param local_filename local filename to upload
-	* @param file_ext_name file ext name, do not include dot(.), null to extract ext name from the local filename
-	* @param meta_list meta info array
-	* @return  file id(including group name and filename) if success, <br>
-	*         return null if fail
-	*/
-	public String upload_appender_file1(String local_filename, String file_ext_name, 
-	       NameValuePair[] meta_list) throws IOException, MyException
-	{
-		String parts[] = this.upload_appender_file(local_filename, file_ext_name, meta_list);
-		if (parts != null)
-		{
-			return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
-		}
-		else
-		{
-			return null;
-		}
-	}
-
-	/**
-	* upload appender file to storage server (by file name)
-	* @param group_name the group name to upload file to, can be empty
-	* @param local_filename local filename to upload
-	* @param file_ext_name file ext name, do not include dot(.), null to extract ext name from the local filename
-	* @param meta_list meta info array
-	* @return  file id(including group name and filename) if success, <br>
-	*         return null if fail
-	*/
-	public String upload_appender_file1(String group_name, String local_filename, String file_ext_name, 
-	       NameValuePair[] meta_list) throws IOException, MyException
-	{
-		String parts[] = this.upload_appender_file(group_name, local_filename, file_ext_name, meta_list);
-		if (parts != null)
-		{
-			return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
-		}
-		else
-		{
-			return null;
-		}
-	}
-	
-	/**
-	* upload appender file to storage server (by file buff)
-	* @param file_buff file content/buff
-	* @param file_ext_name file ext name, do not include dot(.)
-	*	@param meta_list meta info array
-	* @return  file id(including group name and filename) if success, <br>
-	*         return null if fail
-	*/
-	public String upload_appender_file1(byte[] file_buff, String file_ext_name,	
-	       NameValuePair[] meta_list) throws IOException, MyException
-	{
-		String parts[] = this.upload_appender_file(file_buff, file_ext_name, meta_list);
-		if (parts != null)
-		{
-			return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
-		}
-		else
-		{
-			return null;
-		}
-	}
-
-	/**
-	* upload appender file to storage server (by file buff)
-	* @param group_name the group name to upload file to, can be empty
-	* @param file_buff file content/buff
-	* @param file_ext_name file ext name, do not include dot(.)
-	*	@param meta_list meta info array
-	* @return  file id(including group name and filename) if success, <br>
-	*         return null if fail
-	*/
-	public String upload_appender_file1(String group_name, byte[] file_buff, String file_ext_name,	
-	       NameValuePair[] meta_list) throws IOException, MyException
-	{
-		String parts[] = this.upload_appender_file(group_name, file_buff, file_ext_name, meta_list);
-		if (parts != null)
-		{
-			return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
-		}
-		else
-		{
-			return null;
-		}
-	}
-
-	/**
-	* upload appender file to storage server (by callback)
-	* @param group_name the group name to upload file to, can be empty
-	* @param file_size the file size
-	* @param callback the write data callback object
-	* @param file_ext_name file ext name, do not include dot(.)
-	*	@param meta_list meta info array
-  * @return file id(including group name and filename) if success, <br>
-	*         return null if fail
-	*/
-	public String upload_appender_file1(String group_name, long file_size, 
-	       UploadCallback callback, String file_ext_name, 
-	       NameValuePair[] meta_list) throws IOException, MyException
-	{
-		String parts[] = this.upload_appender_file(group_name, file_size, callback, file_ext_name, meta_list);
-		if (parts != null)
-		{
-			return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
-		}
-		else
-		{
-			return null;
-		}
-	}
-	
-	/**
-	* upload file to storage server (by file name, slave file mode)
-	* @param master_file_id the master file id to generate the slave file
-	* @param prefix_name the prefix name to generate the slave file
-	* @param local_filename local filename to upload
-	* @param file_ext_name file ext name, do not include dot(.), null to extract ext name from the local filename
-	* @param meta_list meta info array
-	* @return  file id(including group name and filename) if success, <br>
-	*         return null if fail
-	*/
-	public String upload_file1(String master_file_id, String prefix_name, 
-	       String local_filename, String file_ext_name, NameValuePair[] meta_list) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(master_file_id, parts);
-		if (this.errno != 0)
-		{
-			return null;
-		}
-		
-		parts = this.upload_file(parts[0], parts[1], prefix_name, 
-		                                  local_filename,	file_ext_name, meta_list);
-		if (parts != null)
-		{
-			return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
-		}
-		else
-		{
-			return null;
-		}
-	}
-	
-	/**
-	* upload file to storage server (by file buff, slave file mode)
-	* @param master_file_id the master file id to generate the slave file
-	* @param prefix_name the prefix name to generate the slave file
-	* @param file_buff file content/buff
-	* @param file_ext_name file ext name, do not include dot(.)
-	*	@param meta_list meta info array
-	* @return  file id(including group name and filename) if success, <br>
-	*         return null if fail
-	*/
-	public String upload_file1(String master_file_id, String prefix_name, 
-	       byte[] file_buff, String file_ext_name, NameValuePair[] meta_list) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(master_file_id, parts);
-		if (this.errno != 0)
-		{
-			return null;
-		}
-		
-		parts = this.upload_file(parts[0], parts[1], prefix_name, file_buff, file_ext_name, meta_list);
-		if (parts != null)
-		{
-			return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
-		}
-		else
-		{
-			return null;
-		}
-	}
-
-	/**
-	* upload file to storage server (by file buff, slave file mode)
-	* @param master_file_id the master file id to generate the slave file
-	* @param prefix_name the prefix name to generate the slave file
-	* @param file_buff file content/buff
-	* @param file_ext_name file ext name, do not include dot(.)
-	*	@param meta_list meta info array
-	* @return  file id(including group name and filename) if success, <br>
-	*         return null if fail
-	*/
-	public String upload_file1(String master_file_id, String prefix_name, 
-	       byte[] file_buff, int offset, int length, String file_ext_name, 
-	       NameValuePair[] meta_list) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(master_file_id, parts);
-		if (this.errno != 0)
-		{
-			return null;
-		}
-		
-		parts = this.upload_file(parts[0], parts[1], prefix_name, file_buff, 
-		             offset, length, file_ext_name, meta_list);
-		if (parts != null)
-		{
-			return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
-		}
-		else
-		{
-			return null;
-		}
-	}
-	
-	/**
-	* upload file to storage server (by callback)
-	* @param master_file_id the master file id to generate the slave file
-	* @param prefix_name the prefix name to generate the slave file
-	* @param file_size the file size
-	* @param callback the write data callback object
-	* @param file_ext_name file ext name, do not include dot(.)
-	*	@param meta_list meta info array
-  * @return file id(including group name and filename) if success, <br>
-	*         return null if fail
-	*/
-	public String upload_file1(String master_file_id, String prefix_name, long file_size, 
-	       UploadCallback callback, String file_ext_name, 
-	       NameValuePair[] meta_list) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(master_file_id, parts);
-		if (this.errno != 0)
-		{
-			return null;
-		}
-		
-		parts = this.upload_file(parts[0], parts[1], prefix_name, file_size, callback, file_ext_name, meta_list);
-		if (parts != null)
-		{
-			return parts[0] + SPLIT_GROUP_NAME_AND_FILENAME_SEPERATOR + parts[1];
-		}
-		else
-		{
-			return null;
-		}
-	}
-
-	/**
-	* append file to storage server (by file name)
-	* @param appender_file_id the appender file id
-	* @param local_filename local filename to append
-	* @return 0 for success, != 0 for error (error no)
-	*/
-	public int append_file1(String appender_file_id, String local_filename) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(appender_file_id, parts);
-		if (this.errno != 0)
-		{
-			return this.errno;
-		}
-		
-		return this.append_file(parts[0], parts[1], local_filename);
-	}
-	
-	/**
-	* append file to storage server (by file buff)
-	* @param appender_file_id the appender file id
-	* @param file_buff file content/buff
-	* @return 0 for success, != 0 for error (error no)
-	*/
-	public int append_file1(String appender_file_id, byte[] file_buff) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(appender_file_id, parts);
-		if (this.errno != 0)
-		{
-			return this.errno;
-		}
-		
-		return this.append_file(parts[0], parts[1], file_buff);
-	}
-	
-	/**
-	* append file to storage server (by file buff)
-	* @param appender_file_id the appender file id
-	* @param file_buff file content/buffer
-	* @param offset start offset of the buffer
-	* @param length the length of the buffer to append
-	* @return 0 for success, != 0 for error (error no)
-	*/
-	public int append_file1(String appender_file_id, byte[] file_buff, int offset, int length) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(appender_file_id, parts);
-		if (this.errno != 0)
-		{
-			return this.errno;
-		}
-		
-		return this.append_file(parts[0], parts[1], file_buff, offset, length);
-	}
-
-	/**
-	* append file to storage server (by callback)
-	* @param appender_file_id the appender file id
-	* @param file_size the file size
-	* @param callback the write data callback object
-	* @return 0 for success, != 0 for error (error no)
-	*/
-	public int append_file1(String appender_file_id, long file_size, UploadCallback callback) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(appender_file_id, parts);
-		if (this.errno != 0)
-		{
-			return this.errno;
-		}
-		
-		return this.append_file(parts[0], parts[1], file_size, callback);
-	}
-	
-	/**
-	* modify appender file to storage server (by file name)
-	* @param appender_file_id the appender file id
-	* @param file_offset the offset of appender file
-	* @param local_filename local filename to append
-	* @return 0 for success, != 0 for error (error no)
-	*/
-	public int modify_file1(String appender_file_id, 
-			long file_offset, String local_filename) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(appender_file_id, parts);
-		if (this.errno != 0)
-		{
-			return this.errno;
-		}
-		
-		return this.modify_file(parts[0], parts[1], file_offset, local_filename);
-	}
-	
-	/**
-	* modify appender file to storage server (by file buff)
-	* @param appender_file_id the appender file id
-	* @param file_offset the offset of appender file
-	* @param file_buff file content/buff
-	* @return 0 for success, != 0 for error (error no)
-	*/
-	public int modify_file1(String appender_file_id, 
-			long file_offset, byte[] file_buff) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(appender_file_id, parts);
-		if (this.errno != 0)
-		{
-			return this.errno;
-		}
-		
-		return this.modify_file(parts[0], parts[1], file_offset, file_buff);
-	}
-	
-	/**
-	* modify appender file to storage server (by file buff)
-	* @param appender_file_id the appender file id
-	* @param file_offset the offset of appender file
-	* @param file_buff file content/buff
-	* @param buffer_offset start offset of the buff
-	* @param buffer_length the length of buff to modify
-	* @return 0 for success, != 0 for error (error no)
-	*/
-	public int modify_file1(String appender_file_id, 
-	       long file_offset, byte[] file_buff, int buffer_offset, int buffer_length) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(appender_file_id, parts);
-		if (this.errno != 0)
-		{
-			return this.errno;
-		}
-		
-		return this.modify_file(parts[0], parts[1], file_offset, 
-				file_buff, buffer_offset, buffer_length);
-	}
-	
-	/**
-	* modify appender file to storage server (by callback)
-	* @param appender_file_id the appender file id
-	* @param file_offset the offset of appender file
-	* @param modify_size the modify size
-	* @param callback the write data callback object
-	* @return 0 for success, != 0 for error (error no)
-	*/
-	public int modify_file1(String appender_file_id, 
-	       long file_offset, long modify_size, UploadCallback callback) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(appender_file_id, parts);
-		if (this.errno != 0)
-		{
-			return this.errno;
-		}
-		
-		return this.modify_file(parts[0], parts[1], file_offset, modify_size, callback);
-	}
-	
-	/**
-	* delete file from storage server
-	* @param file_id the file id(including group name and filename)
-	* @return 0 for success, none zero for fail (error code)
-	*/
-	public int delete_file1(String file_id) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(file_id, parts);
-		if (this.errno != 0)
-		{
-			return this.errno;
-		}
-		
-		return this.delete_file(parts[0], parts[1]);
-	}
-
-	/**
-	* truncate appender file to size 0 from storage server
-  * @param appender_file_id the appender file id
-	* @return 0 for success, none zero for fail (error code)
-	*/
-	public int truncate_file1(String appender_file_id) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(appender_file_id, parts);
-		if (this.errno != 0)
-		{
-			return this.errno;
-		}
-		
-		return this.truncate_file(parts[0], parts[1]);
-	}
-	
-	/**
-	* truncate appender file from storage server
-  * @param appender_file_id the appender file id
-	* @param truncated_file_size truncated file size
-	* @return 0 for success, none zero for fail (error code)
-	*/
-	public int truncate_file1(String appender_file_id, long truncated_file_size) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(appender_file_id, parts);
-		if (this.errno != 0)
-		{
-			return this.errno;
-		}
-		
-		return this.truncate_file(parts[0], parts[1], truncated_file_size);
-	}
-	
-	/**
-	* download file from storage server
-	* @param file_id the file id(including group name and filename)
-	* @return file content/buffer, return null if fail
-	*/
-	public byte[] download_file1(String file_id) throws IOException, MyException
-	{
-		final long file_offset = 0;
-		final long download_bytes = 0;
-		
-		return this.download_file1(file_id, file_offset, download_bytes);
-	}
-	
-	/**
-	* download file from storage server
-	* @param file_id the file id(including group name and filename)
-	* @param file_offset the start offset of the file
-	* @param download_bytes download bytes, 0 for remain bytes from offset
-	* @return file content/buff, return null if fail
-	*/
-	public byte[] download_file1(String file_id, long file_offset, long download_bytes) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(file_id, parts);
-		if (this.errno != 0)
-		{
-			return null;
-		}
-		
-		return this.download_file(parts[0], parts[1], file_offset, download_bytes);
-	}
-
-	/**
-	* download file from storage server
-	* @param file_id the file id(including group name and filename)
-	* @param local_filename  the filename on local
-	* @return 0 success, return none zero errno if fail
-	*/
-	public int download_file1(String file_id, String local_filename) throws IOException, MyException
-	{
-		final long file_offset = 0;
-		final long download_bytes = 0;
-		
-		return this.download_file1(file_id, file_offset, download_bytes, local_filename);
-	}
-	
-	/**
-	* download file from storage server
-	* @param file_id the file id(including group name and filename)
-	* @param file_offset the start offset of the file
-	* @param download_bytes download bytes, 0 for remain bytes from offset
-	* @param local_filename  the filename on local
-	* @return 0 success, return none zero errno if fail
-	*/
-	public int download_file1(String file_id, long file_offset, long download_bytes, String local_filename) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(file_id, parts);
-		if (this.errno != 0)
-		{
-			return this.errno;
-		}
-		
-		return this.download_file(parts[0], parts[1], file_offset, download_bytes, local_filename);
-	}
-	
-	/**
-	* download file from storage server
-	* @param file_id the file id(including group name and filename)
-	* @param callback the callback object, will call callback.recv() when data arrive
-	* @return 0 success, return none zero errno if fail
-	*/
-	public int download_file1(String file_id, DownloadCallback callback) throws IOException, MyException
-	{
-		final long file_offset = 0;
-		final long download_bytes = 0;
-		
-		return this.download_file1(file_id, file_offset, download_bytes, callback);
-	}
-	
-	/**
-	* download file from storage server
-	* @param file_id the file id(including group name and filename)
-	* @param file_offset the start offset of the file
-	* @param download_bytes download bytes, 0 for remain bytes from offset
-	* @param callback the callback object, will call callback.recv() when data arrive
-	* @return 0 success, return none zero errno if fail
-	*/
-	public int download_file1(String file_id, long file_offset, long download_bytes, DownloadCallback callback) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(file_id, parts);
-		if (this.errno != 0)
-		{
-			return this.errno;
-		}
-		
-		return this.download_file(parts[0], parts[1], file_offset, download_bytes, callback);
-	}
-
-	/**
-	* get all metadata items from storage server
-	* @param file_id the file id(including group name and filename)
-	* @return meta info array, return null if fail
-	*/
-	public NameValuePair[] get_metadata1(String file_id)throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(file_id, parts);
-		if (this.errno != 0)
-		{
-			return null;
-		}
-		
-		return this.get_metadata(parts[0], parts[1]);
-	}
-	
-	/**
-	* set metadata items to storage server
-	* @param file_id the file id(including group name and filename)
-	*	@param meta_list meta item array
-	* @param op_flag flag, can be one of following values: <br>
-	*            <ul><li> ProtoCommon.STORAGE_SET_METADATA_FLAG_OVERWRITE: overwrite all old
-	*				       metadata items</li></ul>
-	*            <ul><li> ProtoCommon.STORAGE_SET_METADATA_FLAG_MERGE: merge, insert when
-	*				       the metadata item not exist, otherwise update it</li></ul>
-	* @return 0 for success, !=0 fail (error code)
-	*/
-	public int set_metadata1(String file_id, NameValuePair[] meta_list, byte op_flag) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(file_id, parts);
-		if (this.errno != 0)
-		{
-			return this.errno;
-		}
-		
-		return this.set_metadata(parts[0], parts[1], meta_list, op_flag);
-	}
-	
-	/**
-	* get file info from storage server
-	* @param file_id the file id(including group name and filename)
-	* @return FileInfo object for success, return null for fail
-	*/
-	public FileInfo query_file_info1(String file_id) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(file_id, parts);
-		if (this.errno != 0)
-		{
-			return null;
-		}
-		
-		return this.query_file_info(parts[0], parts[1]);
-	}
-	
-	/**
-	* get file info decoded from filename
-	* @param file_id the file id(including group name and filename)
-	* @return FileInfo object for success, return null for fail
-	*/
-	public FileInfo get_file_info1(String file_id) throws IOException, MyException
-	{
-		String[] parts = new String[2];
-		this.errno = this.split_file_id(file_id, parts);
-		if (this.errno != 0)
-		{
-			return null;
-		}
-		
-		return this.get_file_info(parts[0], parts[1]);
-	}
-}

+ 0 - 61
src/main/java/org/csource/fastdfs/StorageServer.java

@@ -1,61 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-*/
-
-package org.csource.fastdfs;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-
-/**
-* Storage Server Info
-* @author Happy Fish / YuQing
-* @version Version 1.11
-*/
-public class StorageServer extends TrackerServer
-{
-	protected int store_path_index = 0;
-	
-/**
-* Constructor
-* @param ip_addr the ip address of storage server
-* @param port the port of storage server
-* @param store_path the store path index on the storage server
-*/
-	public StorageServer(String ip_addr, int port, int store_path) throws IOException
-	{		
-		super(ClientGlobal.getSocket(ip_addr, port), new InetSocketAddress(ip_addr, port));
-		this.store_path_index = store_path;
-	}
-
-/**
-* Constructor
-* @param ip_addr the ip address of storage server
-* @param port the port of storage server
-* @param store_path the store path index on the storage server
-*/
-	public StorageServer(String ip_addr, int port, byte store_path) throws IOException
-	{
-		super(ClientGlobal.getSocket(ip_addr, port), new InetSocketAddress(ip_addr, port));
-		if (store_path < 0)
-		{
-			this.store_path_index = 256 + store_path;
-		}
-		else
-		{
-			this.store_path_index = store_path;
-		}
-	}
-	
-/**
-* @return the store path index on the storage server
-*/
-	public int getStorePathIndex()
-	{
-		return this.store_path_index;
-	}
-}

+ 0 - 79
src/main/java/org/csource/fastdfs/StructBase.java

@@ -1,79 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-*/
-
-package org.csource.fastdfs;
-
-import java.io.UnsupportedEncodingException;
-import java.util.Date;
-
-/**
-* C struct body decoder
-* @author Happy Fish / YuQing
-* @version Version 1.17
-*/
-public abstract class StructBase
-{
-	protected static class FieldInfo
-	{
-		protected String name;
-		protected int offset;
-		protected int size;
-		
-		public FieldInfo(String name, int offset, int size)
-		{
-			this.name = name;
-			this.offset = offset;
-			this.size = size;
-		}
-	}
-	
-/**
-* set fields
-* @param bs byte array
-* @param offset start offset
-*/
-	public abstract void setFields(byte[] bs, int offset);
-	
-	protected String stringValue(byte[] bs, int offset, FieldInfo filedInfo)
-	{
-		try
-		{
-			return (new String(bs, offset + filedInfo.offset, filedInfo.size, ClientGlobal.g_charset)).trim();
-		}
-		catch(UnsupportedEncodingException ex)
-		{
-			ex.printStackTrace();
-			return null;
-		}
-	}
-	
-	protected long longValue(byte[] bs, int offset, FieldInfo filedInfo)
-	{
-		return ProtoCommon.buff2long(bs, offset + filedInfo.offset);
-	}
-	
-	protected int intValue(byte[] bs, int offset, FieldInfo filedInfo)
-	{
-		return (int) ProtoCommon.buff2long(bs, offset + filedInfo.offset);
-	}
-	
-	protected byte byteValue(byte[] bs, int offset, FieldInfo filedInfo)
-	{
-		return bs[offset + filedInfo.offset];
-	}
-
-	protected boolean booleanValue(byte[] bs, int offset, FieldInfo filedInfo)
-	{
-		return bs[offset + filedInfo.offset] != 0;
-	}
-	
-	protected Date dateValue(byte[] bs, int offset, FieldInfo filedInfo)
-	{
-		return new Date(ProtoCommon.buff2long(bs, offset + filedInfo.offset) * 1000);
-	}
-}

+ 0 - 226
src/main/java/org/csource/fastdfs/StructGroupStat.java

@@ -1,226 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-*/
-
-package org.csource.fastdfs;
-
-/**
-* C struct body decoder
-* @author Happy Fish / YuQing
-* @version Version 1.18
-*/
-public class StructGroupStat extends StructBase
-{
-	protected static final int FIELD_INDEX_GROUP_NAME            = 0;
-	protected static final int FIELD_INDEX_TOTAL_MB              = 1;
-	protected static final int FIELD_INDEX_FREE_MB               = 2;
-	protected static final int FIELD_INDEX_TRUNK_FREE_MB         = 3;
-	protected static final int FIELD_INDEX_STORAGE_COUNT         = 4;
-	protected static final int FIELD_INDEX_STORAGE_PORT          = 5;
-	protected static final int FIELD_INDEX_STORAGE_HTTP_PORT     = 6;
-	protected static final int FIELD_INDEX_ACTIVE_COUNT          = 7;
-	protected static final int FIELD_INDEX_CURRENT_WRITE_SERVER  = 8;
-	protected static final int FIELD_INDEX_STORE_PATH_COUNT      = 9;
-	protected static final int FIELD_INDEX_SUBDIR_COUNT_PER_PATH = 10;
-	protected static final int FIELD_INDEX_CURRENT_TRUNK_FILE_ID = 11;
-	
-	protected static int fieldsTotalSize;
-	protected static StructBase.FieldInfo[] fieldsArray = new StructBase.FieldInfo[12];
-	
-	static
-	{
-		int offset = 0;
-		fieldsArray[FIELD_INDEX_GROUP_NAME] = new StructBase.FieldInfo("groupName", offset, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + 1);
-		offset += ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + 1;
-		
-		fieldsArray[FIELD_INDEX_TOTAL_MB] = new StructBase.FieldInfo("totalMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_FREE_MB] = new StructBase.FieldInfo("freeMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_TRUNK_FREE_MB] = new StructBase.FieldInfo("trunkFreeMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-
-		fieldsArray[FIELD_INDEX_STORAGE_COUNT] = new StructBase.FieldInfo("storageCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_STORAGE_PORT] = new StructBase.FieldInfo("storagePort", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_STORAGE_HTTP_PORT] = new StructBase.FieldInfo("storageHttpPort", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_ACTIVE_COUNT] = new StructBase.FieldInfo("activeCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_CURRENT_WRITE_SERVER] = new StructBase.FieldInfo("currentWriteServer", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_STORE_PATH_COUNT] = new StructBase.FieldInfo("storePathCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUBDIR_COUNT_PER_PATH] = new StructBase.FieldInfo("subdirCountPerPath", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-
-		fieldsArray[FIELD_INDEX_CURRENT_TRUNK_FILE_ID] = new StructBase.FieldInfo("currentTrunkFileId", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-				
-		fieldsTotalSize = offset;
-	}
-	
-	protected String groupName;  //name of this group
-	protected long totalMB;      //total disk storage in MB
-	protected long freeMB;       //free disk space in MB
-	protected long trunkFreeMB;  //trunk free space in MB
-	protected int storageCount;  //storage server count
-  protected int storagePort;   //storage server port
-  protected int storageHttpPort; //storage server HTTP port
-  protected int activeCount;     //active storage server count
-  protected int currentWriteServer; //current storage server index to upload file
-  protected int storePathCount;     //store base path count of each storage server
-  protected int subdirCountPerPath; //sub dir count per store path
-	protected int currentTrunkFileId; //current trunk file id
-	
-/**
-* get group name
-* @return group name
-*/
-  public String getGroupName()
-  {
-  	return this.groupName;
-  }
-
-/**
-* get total disk space in MB
-* @return total disk space in MB
-*/
-  public long getTotalMB()
-  {
-  	return this.totalMB;
-  }
-  
-/**
-* get free disk space in MB
-* @return free disk space in MB
-*/
-  public long getFreeMB()
-  {
-  	return this.freeMB;
-  }
-
-/**
-* get trunk free space in MB
-* @return trunk free space in MB
-*/
-  public long getTrunkFreeMB()
-  {
-  	return this.trunkFreeMB;
-  }
-
-/**
-* get storage server count in this group
-* @return storage server count in this group
-*/
-  public int getStorageCount()
-  {
-  	return this.storageCount;
-  }
-  
-/**
-* get active storage server count in this group
-* @return active storage server count in this group
-*/
-  public int getActiveCount()
-  {
-  	return this.activeCount;
-  }
-  
-/**
-* get storage server port
-* @return storage server port
-*/
-  public int getStoragePort()
-  {
-  	return this.storagePort;
-  }
-  
-/**
-* get storage server HTTP port
-* @return storage server HTTP port
-*/
-  public int getStorageHttpPort()
-  {
-  	return this.storageHttpPort;
-  }
-
-/**
-* get current storage server index to upload file
-* @return current storage server index to upload file
-*/
-  public int getCurrentWriteServer()
-  {
-  	return this.currentWriteServer;
-  }
-  
-/**
-* get store base path count of each storage server
-* @return store base path count of each storage server
-*/
-  public int getStorePathCount()
-  {
-  	return this.storePathCount;
-  }
-  
-/**
-* get sub dir count per store path
-* @return sub dir count per store path
-*/
-  public int getSubdirCountPerPath()
-  {
-  	return this.subdirCountPerPath;
-  }
-  
-/**
-* get current trunk file id
-* @return current trunk file id
-*/
-  public int getCurrentTrunkFileId()
-  {
-  	return this.currentTrunkFileId;
-  }
-  
-/**
-* set fields
-* @param bs byte array
-* @param offset start offset
-*/
-	public void setFields(byte[] bs, int offset)
-	{
-		this.groupName = stringValue(bs, offset, fieldsArray[FIELD_INDEX_GROUP_NAME]);
-		this.totalMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_MB]);
-		this.freeMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_FREE_MB]);
-		this.trunkFreeMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_TRUNK_FREE_MB]);
-		this.storageCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORAGE_COUNT]);
-	  this.storagePort = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORAGE_PORT]);
-	  this.storageHttpPort = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORAGE_HTTP_PORT]);
-	  this.activeCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_ACTIVE_COUNT]);
-	  this.currentWriteServer = intValue(bs, offset, fieldsArray[FIELD_INDEX_CURRENT_WRITE_SERVER]);
-	  this.storePathCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORE_PATH_COUNT]);
-	  this.subdirCountPerPath = intValue(bs, offset, fieldsArray[FIELD_INDEX_SUBDIR_COUNT_PER_PATH]);
-	  this.currentTrunkFileId = intValue(bs, offset, fieldsArray[FIELD_INDEX_CURRENT_TRUNK_FILE_ID]);
-	}
-
-/**
-* get fields total size
-* @return fields total size
-*/
-	public static int getFieldsTotalSize()
-	{
-		return fieldsTotalSize;
-	}
-}

+ 0 - 934
src/main/java/org/csource/fastdfs/StructStorageStat.java

@@ -1,934 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-*/
-
-package org.csource.fastdfs;
-
-import java.util.Date;
-
-/**
-* C struct body decoder
-* @author Happy Fish / YuQing
-* @version Version 1.20
-*/
-public class StructStorageStat extends StructBase
-{
-	protected static final int FIELD_INDEX_STATUS                   = 0;
-	protected static final int FIELD_INDEX_ID                       = 1;
-	protected static final int FIELD_INDEX_IP_ADDR                  = 2;
-	protected static final int FIELD_INDEX_DOMAIN_NAME              = 3;
-	protected static final int FIELD_INDEX_SRC_IP_ADDR              = 4;
-	protected static final int FIELD_INDEX_VERSION                  = 5;
-	protected static final int FIELD_INDEX_JOIN_TIME                = 6;
-	protected static final int FIELD_INDEX_UP_TIME                  = 7;
-	protected static final int FIELD_INDEX_TOTAL_MB                 = 8;
-	protected static final int FIELD_INDEX_FREE_MB                  = 9;
-	protected static final int FIELD_INDEX_UPLOAD_PRIORITY          = 10;
-	protected static final int FIELD_INDEX_STORE_PATH_COUNT         = 11;
-	protected static final int FIELD_INDEX_SUBDIR_COUNT_PER_PATH    = 12;
-	protected static final int FIELD_INDEX_CURRENT_WRITE_PATH       = 13;
-	protected static final int FIELD_INDEX_STORAGE_PORT             = 14;
-	protected static final int FIELD_INDEX_STORAGE_HTTP_PORT        = 15;
-	protected static final int FIELD_INDEX_TOTAL_UPLOAD_COUNT       = 16;
-	protected static final int FIELD_INDEX_SUCCESS_UPLOAD_COUNT     = 17;
-	protected static final int FIELD_INDEX_TOTAL_APPEND_COUNT       = 18;
-	protected static final int FIELD_INDEX_SUCCESS_APPEND_COUNT     = 19;
-	protected static final int FIELD_INDEX_TOTAL_MODIFY_COUNT       = 20;
-	protected static final int FIELD_INDEX_SUCCESS_MODIFY_COUNT     = 21;
-	protected static final int FIELD_INDEX_TOTAL_TRUNCATE_COUNT     = 22;
-	protected static final int FIELD_INDEX_SUCCESS_TRUNCATE_COUNT   = 23;
-	protected static final int FIELD_INDEX_TOTAL_SET_META_COUNT     = 24;
-	protected static final int FIELD_INDEX_SUCCESS_SET_META_COUNT   = 25;
-	protected static final int FIELD_INDEX_TOTAL_DELETE_COUNT       = 26;
-	protected static final int FIELD_INDEX_SUCCESS_DELETE_COUNT     = 27;
-	protected static final int FIELD_INDEX_TOTAL_DOWNLOAD_COUNT     = 28;
-	protected static final int FIELD_INDEX_SUCCESS_DOWNLOAD_COUNT   = 29;
-	protected static final int FIELD_INDEX_TOTAL_GET_META_COUNT     = 30;
-	protected static final int FIELD_INDEX_SUCCESS_GET_META_COUNT   = 31;
-	protected static final int FIELD_INDEX_TOTAL_CREATE_LINK_COUNT  = 32;
-	protected static final int FIELD_INDEX_SUCCESS_CREATE_LINK_COUNT= 33;
-	protected static final int FIELD_INDEX_TOTAL_DELETE_LINK_COUNT  = 34;
-	protected static final int FIELD_INDEX_SUCCESS_DELETE_LINK_COUNT= 35;	
-	protected static final int FIELD_INDEX_TOTAL_UPLOAD_BYTES       = 36;
-	protected static final int FIELD_INDEX_SUCCESS_UPLOAD_BYTES     = 37;
-	protected static final int FIELD_INDEX_TOTAL_APPEND_BYTES       = 38;
-	protected static final int FIELD_INDEX_SUCCESS_APPEND_BYTES     = 39;
-	protected static final int FIELD_INDEX_TOTAL_MODIFY_BYTES       = 40;
-	protected static final int FIELD_INDEX_SUCCESS_MODIFY_BYTES     = 41;
-	protected static final int FIELD_INDEX_TOTAL_DOWNLOAD_BYTES     = 42;
-	protected static final int FIELD_INDEX_SUCCESS_DOWNLOAD_BYTES   = 43;
-	protected static final int FIELD_INDEX_TOTAL_SYNC_IN_BYTES      = 44;
-	protected static final int FIELD_INDEX_SUCCESS_SYNC_IN_BYTES    = 45;
-	protected static final int FIELD_INDEX_TOTAL_SYNC_OUT_BYTES     = 46;
-	protected static final int FIELD_INDEX_SUCCESS_SYNC_OUT_BYTES   = 47;
-	protected static final int FIELD_INDEX_TOTAL_FILE_OPEN_COUNT    = 48;
-	protected static final int FIELD_INDEX_SUCCESS_FILE_OPEN_COUNT  = 49;
-	protected static final int FIELD_INDEX_TOTAL_FILE_READ_COUNT    = 50;
-	protected static final int FIELD_INDEX_SUCCESS_FILE_READ_COUNT  = 51;
-	protected static final int FIELD_INDEX_TOTAL_FILE_WRITE_COUNT   = 52;
-	protected static final int FIELD_INDEX_SUCCESS_FILE_WRITE_COUNT = 53;
-	protected static final int FIELD_INDEX_LAST_SOURCE_UPDATE       = 54;
-	protected static final int FIELD_INDEX_LAST_SYNC_UPDATE         = 55;
-	protected static final int FIELD_INDEX_LAST_SYNCED_TIMESTAMP    = 56;
-	protected static final int FIELD_INDEX_LAST_HEART_BEAT_TIME     = 57;
-	protected static final int FIELD_INDEX_IF_TRUNK_FILE            = 58;
-	
-	protected static int fieldsTotalSize;
-	protected static StructBase.FieldInfo[] fieldsArray = new StructBase.FieldInfo[59];
-	
-	static
-	{
-		int offset = 0;
-		
-		fieldsArray[FIELD_INDEX_STATUS] = new StructBase.FieldInfo("status", offset, 1);
-		offset += 1;
-		
-		fieldsArray[FIELD_INDEX_ID] = new StructBase.FieldInfo("id", offset, ProtoCommon.FDFS_STORAGE_ID_MAX_SIZE);
-		offset += ProtoCommon.FDFS_STORAGE_ID_MAX_SIZE;
-		
-		fieldsArray[FIELD_INDEX_IP_ADDR] = new StructBase.FieldInfo("ipAddr", offset, ProtoCommon.FDFS_IPADDR_SIZE);
-		offset += ProtoCommon.FDFS_IPADDR_SIZE;
-		
-		fieldsArray[FIELD_INDEX_DOMAIN_NAME] = new StructBase.FieldInfo("domainName", offset, ProtoCommon.FDFS_DOMAIN_NAME_MAX_SIZE);
-		offset += ProtoCommon.FDFS_DOMAIN_NAME_MAX_SIZE;
-
-		fieldsArray[FIELD_INDEX_SRC_IP_ADDR] = new StructBase.FieldInfo("srcIpAddr", offset, ProtoCommon.FDFS_IPADDR_SIZE);
-		offset += ProtoCommon.FDFS_IPADDR_SIZE;
-				
-		fieldsArray[FIELD_INDEX_VERSION] = new StructBase.FieldInfo("version", offset, ProtoCommon.FDFS_VERSION_SIZE);
-		offset += ProtoCommon.FDFS_VERSION_SIZE;
-		
-		fieldsArray[FIELD_INDEX_JOIN_TIME] = new StructBase.FieldInfo("joinTime", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_UP_TIME] = new StructBase.FieldInfo("upTime", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-
-		fieldsArray[FIELD_INDEX_TOTAL_MB] = new StructBase.FieldInfo("totalMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_FREE_MB] = new StructBase.FieldInfo("freeMB", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-
-		fieldsArray[FIELD_INDEX_UPLOAD_PRIORITY] = new StructBase.FieldInfo("uploadPriority", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-				
-		fieldsArray[FIELD_INDEX_STORE_PATH_COUNT] = new StructBase.FieldInfo("storePathCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUBDIR_COUNT_PER_PATH] = new StructBase.FieldInfo("subdirCountPerPath", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-
-		fieldsArray[FIELD_INDEX_CURRENT_WRITE_PATH] = new StructBase.FieldInfo("currentWritePath", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-
-		fieldsArray[FIELD_INDEX_STORAGE_PORT] = new StructBase.FieldInfo("storagePort", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_STORAGE_HTTP_PORT] = new StructBase.FieldInfo("storageHttpPort", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-				
-		fieldsArray[FIELD_INDEX_TOTAL_UPLOAD_COUNT] = new StructBase.FieldInfo("totalUploadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-				
-		fieldsArray[FIELD_INDEX_SUCCESS_UPLOAD_COUNT] = new StructBase.FieldInfo("successUploadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_TOTAL_APPEND_COUNT] = new StructBase.FieldInfo("totalAppendCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-				
-		fieldsArray[FIELD_INDEX_SUCCESS_APPEND_COUNT] = new StructBase.FieldInfo("successAppendCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-
-		fieldsArray[FIELD_INDEX_TOTAL_MODIFY_COUNT] = new StructBase.FieldInfo("totalModifyCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-				
-		fieldsArray[FIELD_INDEX_SUCCESS_MODIFY_COUNT] = new StructBase.FieldInfo("successModifyCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-
-		fieldsArray[FIELD_INDEX_TOTAL_TRUNCATE_COUNT] = new StructBase.FieldInfo("totalTruncateCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-				
-		fieldsArray[FIELD_INDEX_SUCCESS_TRUNCATE_COUNT] = new StructBase.FieldInfo("successTruncateCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_TOTAL_SET_META_COUNT] = new StructBase.FieldInfo("totalSetMetaCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUCCESS_SET_META_COUNT] = new StructBase.FieldInfo("successSetMetaCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_TOTAL_DELETE_COUNT] = new StructBase.FieldInfo("totalDeleteCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUCCESS_DELETE_COUNT] = new StructBase.FieldInfo("successDeleteCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_TOTAL_DOWNLOAD_COUNT] = new StructBase.FieldInfo("totalDownloadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUCCESS_DOWNLOAD_COUNT] = new StructBase.FieldInfo("successDownloadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_TOTAL_GET_META_COUNT] = new StructBase.FieldInfo("totalGetMetaCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUCCESS_GET_META_COUNT] = new StructBase.FieldInfo("successGetMetaCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_TOTAL_CREATE_LINK_COUNT] = new StructBase.FieldInfo("totalCreateLinkCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUCCESS_CREATE_LINK_COUNT] = new StructBase.FieldInfo("successCreateLinkCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_TOTAL_DELETE_LINK_COUNT] = new StructBase.FieldInfo("totalDeleteLinkCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUCCESS_DELETE_LINK_COUNT] = new StructBase.FieldInfo("successDeleteLinkCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-				
-		fieldsArray[FIELD_INDEX_TOTAL_UPLOAD_BYTES] = new StructBase.FieldInfo("totalUploadBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUCCESS_UPLOAD_BYTES] = new StructBase.FieldInfo("successUploadBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_TOTAL_APPEND_BYTES] = new StructBase.FieldInfo("totalAppendBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUCCESS_APPEND_BYTES] = new StructBase.FieldInfo("successAppendBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_TOTAL_MODIFY_BYTES] = new StructBase.FieldInfo("totalModifyBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUCCESS_MODIFY_BYTES] = new StructBase.FieldInfo("successModifyBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_TOTAL_DOWNLOAD_BYTES] = new StructBase.FieldInfo("totalDownloadloadBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUCCESS_DOWNLOAD_BYTES] = new StructBase.FieldInfo("successDownloadloadBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-
-		fieldsArray[FIELD_INDEX_TOTAL_SYNC_IN_BYTES] = new StructBase.FieldInfo("totalSyncInBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUCCESS_SYNC_IN_BYTES] = new StructBase.FieldInfo("successSyncInBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-
-		fieldsArray[FIELD_INDEX_TOTAL_SYNC_OUT_BYTES] = new StructBase.FieldInfo("totalSyncOutBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUCCESS_SYNC_OUT_BYTES] = new StructBase.FieldInfo("successSyncOutBytes", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_TOTAL_FILE_OPEN_COUNT] = new StructBase.FieldInfo("totalFileOpenCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUCCESS_FILE_OPEN_COUNT] = new StructBase.FieldInfo("successFileOpenCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-
-		fieldsArray[FIELD_INDEX_TOTAL_FILE_READ_COUNT] = new StructBase.FieldInfo("totalFileReadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUCCESS_FILE_READ_COUNT] = new StructBase.FieldInfo("successFileReadCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_TOTAL_FILE_WRITE_COUNT] = new StructBase.FieldInfo("totalFileWriteCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_SUCCESS_FILE_WRITE_COUNT] = new StructBase.FieldInfo("successFileWriteCount", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-        
-		fieldsArray[FIELD_INDEX_LAST_SOURCE_UPDATE] = new StructBase.FieldInfo("lastSourceUpdate", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_LAST_SYNC_UPDATE] = new StructBase.FieldInfo("lastSyncUpdate", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_LAST_SYNCED_TIMESTAMP] = new StructBase.FieldInfo("lastSyncedTimestamp", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_LAST_HEART_BEAT_TIME] = new StructBase.FieldInfo("lastHeartBeatTime", offset, ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE);
-		offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		
-		fieldsArray[FIELD_INDEX_IF_TRUNK_FILE] = new StructBase.FieldInfo("ifTrunkServer", offset, 1);
-		offset += 1;
-		
-		fieldsTotalSize = offset;
-	}
-	
-	protected byte status;
-	protected String id;
-	protected String ipAddr;
-	protected String srcIpAddr;
-	protected String domainName; //http domain name
-	protected String version;
-	protected long totalMB; //total disk storage in MB
-	protected long freeMB;  //free disk storage in MB
-	protected int uploadPriority;  //upload priority
-	protected Date joinTime; //storage join timestamp (create timestamp)
-	protected Date upTime;   //storage service started timestamp
-	protected int storePathCount;  //store base path count of each storage server
-	protected int subdirCountPerPath;
-	protected int storagePort;
-	protected int storageHttpPort; //storage http server port
-	protected int currentWritePath; //current write path index
-	protected long totalUploadCount;
-	protected long successUploadCount;
-	protected long totalAppendCount;
-	protected long successAppendCount;
-	protected long totalModifyCount;
-	protected long successModifyCount;
-	protected long totalTruncateCount;
-	protected long successTruncateCount;
-	protected long totalSetMetaCount;
-	protected long successSetMetaCount;
-	protected long totalDeleteCount;
-	protected long successDeleteCount;
-	protected long totalDownloadCount;
-	protected long successDownloadCount;
-	protected long totalGetMetaCount;
-	protected long successGetMetaCount;
-	protected long totalCreateLinkCount;
-	protected long successCreateLinkCount;
-	protected long totalDeleteLinkCount;
-	protected long successDeleteLinkCount;
-	protected long totalUploadBytes;
-	protected long successUploadBytes;
-	protected long totalAppendBytes;
-	protected long successAppendBytes;
-	protected long totalModifyBytes;
-	protected long successModifyBytes;
-	protected long totalDownloadloadBytes;
-	protected long successDownloadloadBytes;
-	protected long totalSyncInBytes;
-	protected long successSyncInBytes;
-	protected long totalSyncOutBytes;
-	protected long successSyncOutBytes;
-	protected long totalFileOpenCount;
-	protected long successFileOpenCount;
-	protected long totalFileReadCount;
-	protected long successFileReadCount;
-	protected long totalFileWriteCount;
-	protected long successFileWriteCount;
-	protected Date lastSourceUpdate;
-	protected Date lastSyncUpdate;
-	protected Date lastSyncedTimestamp;
-	protected Date lastHeartBeatTime;
-  protected boolean ifTrunkServer;
-  
-/**
-* get storage status
-* @return storage status
-*/
-  public byte getStatus()
-  {
-  	return this.status;
-  }
-  
-/**
-* get storage server id
-* @return storage server id
-*/
-  public String getId()
-  {
-  	return this.id;
-  }
-
-/**
-* get storage server ip address
-* @return storage server ip address
-*/
-  public String getIpAddr()
-  {
-  	return this.ipAddr;
-  }
-  
-/**
-* get source storage ip address
-* @return source storage ip address
-*/
-  public String getSrcIpAddr()
-  {
-  	return this.srcIpAddr;
-  }
-  
-/**
-* get the domain name of the storage server
-* @return the domain name of the storage server
-*/
-  public String getDomainName()
-  {
-  	return this.domainName;
-  }
-
-/**
-* get storage version
-* @return storage version
-*/
-  public String getVersion()
-  {
-  	return this.version;
-  }
-  
-/**
-* get total disk space in MB
-* @return total disk space in MB
-*/
-  public long getTotalMB()
-  {
-  	return this.totalMB;
-  }
-  
-/**
-* get free disk space in MB
-* @return free disk space in MB
-*/
-  public long getFreeMB()
-  {
-  	return this.freeMB;
-  }
-	
-/**
-* get storage server upload priority
-* @return storage server upload priority
-*/
-  public int getUploadPriority()
-  {
-  	return this.uploadPriority;
-  }
-  
-/**
-* get storage server join time
-* @return storage server join time
-*/
-  public Date getJoinTime()
-  {
-  	return this.joinTime;
-  }
-  
-/**
-* get storage server up time
-* @return storage server up time
-*/
-  public Date getUpTime()
-  {
-  	return this.upTime;
-  }
-
-/**
-* get store base path count of each storage server
-* @return store base path count of each storage server
-*/
-  public int getStorePathCount()
-  {
-  	return this.storePathCount;
-  }
-  
-/**
-* get sub dir count per store path
-* @return sub dir count per store path
-*/
-  public int getSubdirCountPerPath()
-  {
-  	return this.subdirCountPerPath;
-  }
-  
-/**
-* get storage server port
-* @return storage server port
-*/
-  public int getStoragePort()
-  {
-  	return this.storagePort;
-  }
-  
-/**
-* get storage server HTTP port
-* @return storage server HTTP port
-*/
-  public int getStorageHttpPort()
-  {
-  	return this.storageHttpPort;
-  }
-
-/**
-* get current write path index
-* @return current write path index
-*/
-  public int getCurrentWritePath()
-  {
-  	return this.currentWritePath;
-  }
-
-/**
-* get total upload file count
-* @return total upload file count
-*/
-  public long getTotalUploadCount()
-  {
-  	return this.totalUploadCount;
-  }
-
-/**
-* get success upload file count
-* @return success upload file count
-*/
-  public long getSuccessUploadCount()
-  {
-  	return this.successUploadCount;
-  }
-
-/**
-* get total append count
-* @return total append count
-*/
-  public long getTotalAppendCount()
-  {
-  	return this.totalAppendCount;
-  }
-
-/**
-* get success append count
-* @return success append count
-*/
-  public long getSuccessAppendCount()
-  {
-  	return this.successAppendCount;
-  }
-  
-/**
-* get total modify count
-* @return total modify count
-*/
-  public long getTotalModifyCount()
-  {
-  	return this.totalModifyCount;
-  }
-
-/**
-* get success modify count
-* @return success modify count
-*/
-  public long getSuccessModifyCount()
-  {
-  	return this.successModifyCount;
-  }
-  
-/**
-* get total truncate count
-* @return total truncate count
-*/
-  public long getTotalTruncateCount()
-  {
-  	return this.totalTruncateCount;
-  }
-
-/**
-* get success truncate count
-* @return success truncate count
-*/
-  public long getSuccessTruncateCount()
-  {
-  	return this.successTruncateCount;
-  }
-  
-/**
-* get total set meta data count
-* @return total set meta data count
-*/
-  public long getTotalSetMetaCount()
-  {
-  	return this.totalSetMetaCount;
-  }
-  
-/**
-* get success set meta data count
-* @return success set meta data count
-*/
-  public long getSuccessSetMetaCount()
-  {
-  	return this.successSetMetaCount;
-  }
-  
-/**
-* get total delete file count
-* @return total delete file count
-*/
-  public long getTotalDeleteCount()
-  {
-  	return this.totalDeleteCount;
-  }
-
-/**
-* get success delete file count
-* @return success delete file count
-*/
-  public long getSuccessDeleteCount()
-  {
-  	return this.successDeleteCount;
-  }
-  
-/**
-* get total download file count
-* @return total download file count
-*/
-  public long getTotalDownloadCount()
-  {
-  	return this.totalDownloadCount;
-  }
-
-/**
-* get success download file count
-* @return success download file count
-*/
-  public long getSuccessDownloadCount()
-  {
-  	return this.successDownloadCount;
-  }
-
-/**
-* get total get metadata count
-* @return total get metadata count
-*/
-  public long getTotalGetMetaCount()
-  {
-  	return this.totalGetMetaCount;
-  }
-
-/**
-* get success get metadata count
-* @return success get metadata count
-*/
-  public long getSuccessGetMetaCount()
-  {
-  	return this.successGetMetaCount;
-  }
-
-/**
-* get total create linke count
-* @return total create linke count
-*/
-  public long getTotalCreateLinkCount()
-  {
-  	return this.totalCreateLinkCount;
-  }
-
-/**
-* get success create linke count
-* @return success create linke count
-*/
-  public long getSuccessCreateLinkCount()
-  {
-  	return this.successCreateLinkCount;
-  }
-  
-/**
-* get total delete link count
-* @return total delete link count
-*/
-  public long getTotalDeleteLinkCount()
-  {
-  	return this.totalDeleteLinkCount;
-  }
-  
-/**
-* get success delete link count
-* @return success delete link count
-*/
-  public long getSuccessDeleteLinkCount()
-  {
-  	return this.successDeleteLinkCount;
-  }
-
-/**
-* get total upload file bytes
-* @return total upload file bytes
-*/
-  public long getTotalUploadBytes()
-  {
-  	return this.totalUploadBytes;
-  }
-  
-/**
-* get success upload file bytes
-* @return success upload file bytes
-*/
-  public long getSuccessUploadBytes()
-  {
-  	return this.successUploadBytes;
-  }
-
-/**
-* get total append bytes
-* @return total append bytes
-*/
-  public long getTotalAppendBytes()
-  {
-  	return this.totalAppendBytes;
-  }
-  
-/**
-* get success append bytes
-* @return success append bytes
-*/
-  public long getSuccessAppendBytes()
-  {
-  	return this.successAppendBytes;
-  }
-
-/**
-* get total modify bytes
-* @return total modify bytes
-*/
-  public long getTotalModifyBytes()
-  {
-  	return this.totalModifyBytes;
-  }
-  
-/**
-* get success modify bytes
-* @return success modify bytes
-*/
-  public long getSuccessModifyBytes()
-  {
-  	return this.successModifyBytes;
-  }
-  
-/**
-* get total download file bytes
-* @return total download file bytes
-*/
-  public long getTotalDownloadloadBytes()
-  {
-  	return this.totalDownloadloadBytes;
-  }
-  
-/**
-* get success download file bytes
-* @return success download file bytes
-*/
-  public long getSuccessDownloadloadBytes()
-  {
-  	return this.successDownloadloadBytes;
-  }
-
-/**
-* get total sync in bytes
-* @return total sync in bytes
-*/
-  public long getTotalSyncInBytes()
-  {
-  	return this.totalSyncInBytes;
-  }
-  
-/**
-* get success sync in bytes
-* @return success sync in bytes
-*/
-  public long getSuccessSyncInBytes()
-  {
-  	return this.successSyncInBytes;
-  }
-
-/**
-* get total sync out bytes
-* @return total sync out bytes
-*/
-  public long getTotalSyncOutBytes()
-  {
-  	return this.totalSyncOutBytes;
-  }
-  
-/**
-* get success sync out bytes
-* @return success sync out bytes
-*/
-  public long getSuccessSyncOutBytes()
-  {
-  	return this.successSyncOutBytes;
-  }
-
-/**
-* get total file opened count
-* @return total file opened bytes
-*/
-  public long getTotalFileOpenCount()
-  {
-  	return this.totalFileOpenCount;
-  }
-  
-/**
-* get success file opened count
-* @return success file opened count
-*/
-  public long getSuccessFileOpenCount()
-  {
-  	return this.successFileOpenCount;
-  }
-
-/**
-* get total file read count
-* @return total file read bytes
-*/
-  public long getTotalFileReadCount()
-  {
-  	return this.totalFileReadCount;
-  }
-  
-/**
-* get success file read count
-* @return success file read count
-*/
-  public long getSuccessFileReadCount()
-  {
-  	return this.successFileReadCount;
-  }
-
-/**
-* get total file write count
-* @return total file write bytes
-*/
-  public long getTotalFileWriteCount()
-  {
-  	return this.totalFileWriteCount;
-  }
-  
-/**
-* get success file write count
-* @return success file write count
-*/
-  public long getSuccessFileWriteCount()
-  {
-  	return this.successFileWriteCount;
-  }
-  
-/**
-* get last source update timestamp
-* @return last source update timestamp
-*/
-  public Date getLastSourceUpdate()
-  {
-  	return this.lastSourceUpdate;
-  }
-
-/**
-* get last synced update timestamp
-* @return last synced update timestamp
-*/
-  public Date getLastSyncUpdate()
-  {
-  	return this.lastSyncUpdate;
-  }
-  
-/**
-* get last synced timestamp
-* @return last synced timestamp
-*/
-  public Date getLastSyncedTimestamp()
-  {
-  	return this.lastSyncedTimestamp;
-  }
-
-/**
-* get last heart beat timestamp
-* @return last heart beat timestamp
-*/
-  public Date getLastHeartBeatTime()
-  {
-  	return this.lastHeartBeatTime;
-  }
-
-/**
-* if the trunk server
-* @return true for the trunk server, otherwise false
-*/
-  public boolean isTrunkServer()
-  {
-  	return this.ifTrunkServer;
-  }
-  
-/**
-* set fields
-* @param bs byte array
-* @param offset start offset
-*/
-	public void setFields(byte[] bs, int offset)
-	{
-		this.status = byteValue(bs, offset, fieldsArray[FIELD_INDEX_STATUS]);
-		this.id = stringValue(bs, offset, fieldsArray[FIELD_INDEX_ID]);
-		this.ipAddr = stringValue(bs, offset, fieldsArray[FIELD_INDEX_IP_ADDR]);
-		this.srcIpAddr = stringValue(bs, offset, fieldsArray[FIELD_INDEX_SRC_IP_ADDR]);
-		this.domainName = stringValue(bs, offset, fieldsArray[FIELD_INDEX_DOMAIN_NAME]);
-		this.version = stringValue(bs, offset, fieldsArray[FIELD_INDEX_VERSION]);
-		this.totalMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_MB]);
-		this.freeMB = longValue(bs, offset, fieldsArray[FIELD_INDEX_FREE_MB]);
-		this.uploadPriority = intValue(bs, offset, fieldsArray[FIELD_INDEX_UPLOAD_PRIORITY]);
-		this.joinTime = dateValue(bs, offset, fieldsArray[FIELD_INDEX_JOIN_TIME]);
-		this.upTime = dateValue(bs, offset, fieldsArray[FIELD_INDEX_UP_TIME]);
-	  this.storePathCount = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORE_PATH_COUNT]);
-	  this.subdirCountPerPath = intValue(bs, offset, fieldsArray[FIELD_INDEX_SUBDIR_COUNT_PER_PATH]);
-	  this.storagePort = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORAGE_PORT]);
-	  this.storageHttpPort = intValue(bs, offset, fieldsArray[FIELD_INDEX_STORAGE_HTTP_PORT]);
-	  this.currentWritePath = intValue(bs, offset, fieldsArray[FIELD_INDEX_CURRENT_WRITE_PATH]);
-		this.totalUploadCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_UPLOAD_COUNT]);
-		this.successUploadCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_UPLOAD_COUNT]);
-		this.totalAppendCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_APPEND_COUNT]);
-		this.successAppendCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_APPEND_COUNT]);
-		this.totalModifyCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_MODIFY_COUNT]);
-		this.successModifyCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_MODIFY_COUNT]);
-		this.totalTruncateCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_TRUNCATE_COUNT]);
-		this.successTruncateCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_TRUNCATE_COUNT]);
-		this.totalSetMetaCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_SET_META_COUNT]);
-		this.successSetMetaCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_SET_META_COUNT]);
-		this.totalDeleteCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_DELETE_COUNT]);
-		this.successDeleteCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_DELETE_COUNT]);
-		this.totalDownloadCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_DOWNLOAD_COUNT]);
-		this.successDownloadCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_DOWNLOAD_COUNT]);
-		this.totalGetMetaCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_GET_META_COUNT]);
-		this.successGetMetaCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_GET_META_COUNT]);
-		this.totalCreateLinkCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_CREATE_LINK_COUNT]);
-		this.successCreateLinkCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_CREATE_LINK_COUNT]);
-		this.totalDeleteLinkCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_DELETE_LINK_COUNT]);
-		this.successDeleteLinkCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_DELETE_LINK_COUNT]);
-		this.totalUploadBytes = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_UPLOAD_BYTES]);
-		this.successUploadBytes = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_UPLOAD_BYTES]);
-		this.totalAppendBytes = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_APPEND_BYTES]);
-		this.successAppendBytes = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_APPEND_BYTES]);
-		this.totalModifyBytes = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_MODIFY_BYTES]);
-		this.successModifyBytes = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_MODIFY_BYTES]);
-		this.totalDownloadloadBytes = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_DOWNLOAD_BYTES]);
-		this.successDownloadloadBytes = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_DOWNLOAD_BYTES]);
-		this.totalSyncInBytes = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_SYNC_IN_BYTES]);
-		this.successSyncInBytes = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_SYNC_IN_BYTES]);
-		this.totalSyncOutBytes = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_SYNC_OUT_BYTES]);
-		this.successSyncOutBytes = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_SYNC_OUT_BYTES]);
-		this.totalFileOpenCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_FILE_OPEN_COUNT]);
-		this.successFileOpenCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_FILE_OPEN_COUNT]);
-		this.totalFileReadCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_FILE_READ_COUNT]);
-		this.successFileReadCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_FILE_READ_COUNT]);
-		this.totalFileWriteCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_TOTAL_FILE_WRITE_COUNT]);
-		this.successFileWriteCount = longValue(bs, offset, fieldsArray[FIELD_INDEX_SUCCESS_FILE_WRITE_COUNT]);
-		this.lastSourceUpdate = dateValue(bs, offset, fieldsArray[FIELD_INDEX_LAST_SOURCE_UPDATE]);
-		this.lastSyncUpdate = dateValue(bs, offset, fieldsArray[FIELD_INDEX_LAST_SYNC_UPDATE]);
-		this.lastSyncedTimestamp = dateValue(bs, offset, fieldsArray[FIELD_INDEX_LAST_SYNCED_TIMESTAMP]);
-		this.lastHeartBeatTime = dateValue(bs, offset, fieldsArray[FIELD_INDEX_LAST_HEART_BEAT_TIME]);
-		this.ifTrunkServer = booleanValue(bs, offset, fieldsArray[FIELD_INDEX_IF_TRUNK_FILE]);
-	}
-
-/**
-* get fields total size
-* @return fields total size
-*/
-	public static int getFieldsTotalSize()
-	{
-		return fieldsTotalSize;
-	}
-}

+ 0 - 990
src/main/java/org/csource/fastdfs/TrackerClient.java

@@ -1,990 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-*/
-
-package org.csource.fastdfs;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.Socket;
-import java.util.Arrays;
-
-/**
-* Tracker client
-* @author Happy Fish / YuQing
-* @version Version 1.19
-*/
-public class TrackerClient
-{
-	protected TrackerGroup tracker_group;
-  protected byte errno;
-  
-/**
-* constructor with global tracker group
-*/
-	public TrackerClient()
-	{
-		this.tracker_group = ClientGlobal.g_tracker_group;
-	}
-	
-/**
-* constructor with specified tracker group
-* @param tracker_group the tracker group object
-*/
-	public TrackerClient(TrackerGroup tracker_group)
-	{
-		this.tracker_group = tracker_group;
-	}
-	
-/**
-* get the error code of last call
-* @return the error code of last call
-*/
-	public byte getErrorCode()
-	{
-		return this.errno;
-	}
-	
-	/**
-	* get a connection to tracker server
-	* @return tracker server Socket object, return null if fail
-	*/
-	public TrackerServer getConnection() throws IOException
-	{
-		return this.tracker_group.getConnection();
-	}
-	
-	/**
-	* query storage server to upload file
-	* @param trackerServer the tracker server
-	* @return storage server Socket object, return null if fail
-	*/
-	public StorageServer getStoreStorage(TrackerServer trackerServer) throws IOException
-	{
-		final String groupName = null;
-		return this.getStoreStorage(trackerServer, groupName);
-	}
-	
-	/**
-	* query storage server to upload file
-	* @param trackerServer the tracker server
-	* @param groupName the group name to upload file to, can be empty
-	* @return storage server object, return null if fail
-	*/
-	public StorageServer getStoreStorage(TrackerServer trackerServer, String groupName) throws IOException
-	{
-		byte[] header;
-		String ip_addr;
-		int port;
-		byte cmd;
-		int out_len;
-		boolean bNewConnection;
-		byte store_path;
-		Socket trackerSocket;
-		
-		if (trackerServer == null)
-		{
-			trackerServer = getConnection();
-			if (trackerServer == null)
-			{
-				return null;
-			}
-			bNewConnection = true;
-		}
-		else
-		{
-			bNewConnection = false;
-		}
-
-		trackerSocket = trackerServer.getSocket();
-		OutputStream out = trackerSocket.getOutputStream();
-		
-		try
-		{
-			if (groupName == null || groupName.length() == 0)
-			{
-				cmd = ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITHOUT_GROUP_ONE;
-				out_len = 0;
-			}
-			else
-			{
-				cmd = ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITH_GROUP_ONE;
-				out_len = ProtoCommon.FDFS_GROUP_NAME_MAX_LEN;
-			}
-			header = ProtoCommon.packHeader(cmd, out_len, (byte)0);
-			out.write(header);
-
-			if (groupName != null && groupName.length() > 0)
-			{
-				byte[] bGroupName;
-				byte[] bs;
-				int group_len;
-				
-				bs = groupName.getBytes(ClientGlobal.g_charset);
-				bGroupName = new byte[ProtoCommon.FDFS_GROUP_NAME_MAX_LEN];
-				
-				if (bs.length <= ProtoCommon.FDFS_GROUP_NAME_MAX_LEN)
-				{
-					group_len = bs.length;
-				}
-				else
-				{
-					group_len = ProtoCommon.FDFS_GROUP_NAME_MAX_LEN;
-				}
-				Arrays.fill(bGroupName, (byte)0);
-				System.arraycopy(bs, 0, bGroupName, 0, group_len);
-				out.write(bGroupName);
-			}
-	
-			ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(trackerSocket.getInputStream(), 
-	                                     ProtoCommon.TRACKER_PROTO_CMD_RESP, 
-	                                     ProtoCommon.TRACKER_QUERY_STORAGE_STORE_BODY_LEN);
-			this.errno = pkgInfo.errno;
-			if (pkgInfo.errno != 0)
-			{
-				return null;
-			}
-			
-			ip_addr = new String(pkgInfo.body, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN, ProtoCommon.FDFS_IPADDR_SIZE-1).trim();
-	
-			port = (int)ProtoCommon.buff2long(pkgInfo.body, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN
-	                        + ProtoCommon.FDFS_IPADDR_SIZE-1);
-			store_path = pkgInfo.body[ProtoCommon.TRACKER_QUERY_STORAGE_STORE_BODY_LEN - 1];
-			
-			return new StorageServer(ip_addr, port, store_path);
-		}
-		catch(IOException ex)
-		{
-			if (!bNewConnection)
-			{
-				try
-				{
-					trackerServer.close();
-				}
-				catch(IOException ex1)
-				{
-					ex1.printStackTrace();
-				}
-			}
-			
-			throw ex;
-		}
-		finally
-		{
-			if (bNewConnection)
-			{
-				try
-				{
-					trackerServer.close();
-				}
-				catch(IOException ex1)
-				{
-					ex1.printStackTrace();
-				}
-			}
-		}
-	}
-
-	/**
-	* query storage servers to upload file
-	* @param trackerServer the tracker server
-	* @param groupName the group name to upload file to, can be empty
-	* @return storage servers, return null if fail
-	*/
-	public StorageServer[] getStoreStorages(TrackerServer trackerServer, String groupName) throws IOException
-	{
-		byte[] header;
-		String ip_addr;
-		int port;
-		byte cmd;
-		int out_len;
-		boolean bNewConnection;
-		Socket trackerSocket;
-		
-		if (trackerServer == null)
-		{
-			trackerServer = getConnection();
-			if (trackerServer == null)
-			{
-				return null;
-			}
-			bNewConnection = true;
-		}
-		else
-		{
-			bNewConnection = false;
-		}
-
-		trackerSocket = trackerServer.getSocket();
-		OutputStream out = trackerSocket.getOutputStream();
-		
-		try
-		{
-			if (groupName == null || groupName.length() == 0)
-			{
-				cmd = ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITHOUT_GROUP_ALL;
-				out_len = 0;
-			}
-			else
-			{
-				cmd = ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_STORE_WITH_GROUP_ALL;
-				out_len = ProtoCommon.FDFS_GROUP_NAME_MAX_LEN;
-			}
-			header = ProtoCommon.packHeader(cmd, out_len, (byte)0);
-			out.write(header);
-
-			if (groupName != null && groupName.length() > 0)
-			{
-				byte[] bGroupName;
-				byte[] bs;
-				int group_len;
-				
-				bs = groupName.getBytes(ClientGlobal.g_charset);
-				bGroupName = new byte[ProtoCommon.FDFS_GROUP_NAME_MAX_LEN];
-				
-				if (bs.length <= ProtoCommon.FDFS_GROUP_NAME_MAX_LEN)
-				{
-					group_len = bs.length;
-				}
-				else
-				{
-					group_len = ProtoCommon.FDFS_GROUP_NAME_MAX_LEN;
-				}
-				Arrays.fill(bGroupName, (byte)0);
-				System.arraycopy(bs, 0, bGroupName, 0, group_len);
-				out.write(bGroupName);
-			}
-	
-			ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(trackerSocket.getInputStream(), 
-	                                     ProtoCommon.TRACKER_PROTO_CMD_RESP, -1);
-			this.errno = pkgInfo.errno;
-			if (pkgInfo.errno != 0)
-			{
-				return null;
-			}
-			
-			if (pkgInfo.body.length < ProtoCommon.TRACKER_QUERY_STORAGE_STORE_BODY_LEN)
-			{
-				this.errno = ProtoCommon.ERR_NO_EINVAL;
-				return null;
-			}
-			
-			int ipPortLen = pkgInfo.body.length - (ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + 1);
-			final int recordLength = ProtoCommon.FDFS_IPADDR_SIZE - 1 + ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-			
-			if (ipPortLen % recordLength != 0)
-			{
-				this.errno = ProtoCommon.ERR_NO_EINVAL;
-				return null;
-			}
-			
-			int serverCount = ipPortLen / recordLength;
-			if (serverCount > 16)
-			{
-				this.errno = ProtoCommon.ERR_NO_ENOSPC;
-				return null;
-			}
-			
-			StorageServer[] results = new StorageServer[serverCount];
-			byte store_path = pkgInfo.body[pkgInfo.body.length - 1];
-			int offset = ProtoCommon.FDFS_GROUP_NAME_MAX_LEN;
-			
-			for (int i=0; i<serverCount; i++)
-			{
-				ip_addr = new String(pkgInfo.body, offset, ProtoCommon.FDFS_IPADDR_SIZE - 1).trim();
-				offset += ProtoCommon.FDFS_IPADDR_SIZE - 1;
-				
-				port = (int)ProtoCommon.buff2long(pkgInfo.body, offset);
-		    offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-		    
-		    results[i] = new StorageServer(ip_addr, port, store_path);
-	    }
-	    
-			return results;
-		}
-		catch(IOException ex)
-		{
-			if (!bNewConnection)
-			{
-				try
-				{
-					trackerServer.close();
-				}
-				catch(IOException ex1)
-				{
-					ex1.printStackTrace();
-				}
-			}
-			
-			throw ex;
-		}
-		finally
-		{
-			if (bNewConnection)
-			{
-				try
-				{
-					trackerServer.close();
-				}
-				catch(IOException ex1)
-				{
-					ex1.printStackTrace();
-				}
-			}
-		}
-	}
-	
-	/**
-	* query storage server to download file
-	* @param trackerServer the tracker server
-	*	@param groupName the group name of storage server
-	* @param filename filename on storage server
-	* @return storage server Socket object, return null if fail
-	*/
-	public StorageServer getFetchStorage(TrackerServer trackerServer, 
-			String groupName, String filename) throws IOException
-	{
-		ServerInfo[] servers = this.getStorages(trackerServer, ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ONE,
-				groupName, filename);
-		if (servers == null)
-		{
-				return null;
-		}
-		else
-		{
-			return new StorageServer(servers[0].getIpAddr(), servers[0].getPort(), 0);
-		}
-	}
-
-	/**
-	* query storage server to update file (delete file or set meta data)
-	* @param trackerServer the tracker server
-	*	@param groupName the group name of storage server
-	* @param filename filename on storage server
-	* @return storage server Socket object, return null if fail
-	*/
-	public StorageServer getUpdateStorage(TrackerServer trackerServer, 
-			String groupName, String filename) throws IOException
-	{
-		ServerInfo[] servers = this.getStorages(trackerServer, ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_UPDATE,
-				groupName, filename);
-		if (servers == null)
-		{
-				return null;
-		}
-		else
-		{
-			return new StorageServer(servers[0].getIpAddr(), servers[0].getPort(), 0);
-		} 
-	}
-
-	/**
-	* get storage servers to download file
-	* @param trackerServer the tracker server
-	*	@param groupName the group name of storage server
-	* @param filename filename on storage server
-	* @return storage servers, return null if fail
-	*/
-	public ServerInfo[] getFetchStorages(TrackerServer trackerServer,
-                                         String groupName, String filename) throws IOException
-	{
-		return this.getStorages(trackerServer, ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ALL, 
-				groupName, filename);
-	}
-	
-	/**
-	* query storage server to download file
-	* @param trackerServer the tracker server
-	* @param cmd command code, ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_FETCH_ONE or 
-	                     ProtoCommon.TRACKER_PROTO_CMD_SERVICE_QUERY_UPDATE
-	*	@param groupName the group name of storage server
-	* @param filename filename on storage server
-	* @return storage server Socket object, return null if fail
-	*/
-	protected ServerInfo[] getStorages(TrackerServer trackerServer,
-                                       byte cmd, String groupName, String filename) throws IOException
-	{
-		byte[] header;
-		byte[] bFileName;
-		byte[] bGroupName;
-		byte[] bs;
-		int len;
-		String ip_addr;
-		int port;
-		boolean bNewConnection;
-		Socket trackerSocket;
-		
-		if (trackerServer == null)
-		{
-			trackerServer = getConnection();
-			if (trackerServer == null)
-			{
-				return null;
-			}
-			bNewConnection = true;
-		}
-		else
-		{
-			bNewConnection = false;
-		}
-		trackerSocket = trackerServer.getSocket();
-		OutputStream out = trackerSocket.getOutputStream();
-		
-		try
-		{
-			bs = groupName.getBytes(ClientGlobal.g_charset);
-			bGroupName = new byte[ProtoCommon.FDFS_GROUP_NAME_MAX_LEN];
-			bFileName = filename.getBytes(ClientGlobal.g_charset);
-			
-			if (bs.length <= ProtoCommon.FDFS_GROUP_NAME_MAX_LEN)
-			{
-				len = bs.length;
-			}
-			else
-			{
-				len = ProtoCommon.FDFS_GROUP_NAME_MAX_LEN;
-			}
-			Arrays.fill(bGroupName, (byte)0);
-			System.arraycopy(bs, 0, bGroupName, 0, len);
-			
-			header = ProtoCommon.packHeader(cmd, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + bFileName.length, (byte)0);
-			byte[] wholePkg = new byte[header.length + bGroupName.length + bFileName.length];
-			System.arraycopy(header, 0, wholePkg, 0, header.length);
-			System.arraycopy(bGroupName, 0, wholePkg, header.length, bGroupName.length);
-			System.arraycopy(bFileName, 0, wholePkg, header.length + bGroupName.length, bFileName.length);
-			out.write(wholePkg);
-			
-			ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(trackerSocket.getInputStream(), 
-	                                     ProtoCommon.TRACKER_PROTO_CMD_RESP, -1);
-			this.errno = pkgInfo.errno;
-			if (pkgInfo.errno != 0)
-			{
-				return null;
-			}
-			
-			if (pkgInfo.body.length < ProtoCommon.TRACKER_QUERY_STORAGE_FETCH_BODY_LEN)
-			{
-				throw new IOException("Invalid body length: " + pkgInfo.body.length);
-			}
-			
-			if ((pkgInfo.body.length - ProtoCommon.TRACKER_QUERY_STORAGE_FETCH_BODY_LEN) % (ProtoCommon.FDFS_IPADDR_SIZE - 1) != 0)
-			{
-				throw new IOException("Invalid body length: " + pkgInfo.body.length);
-			}
-			
-			int server_count = 1 + (pkgInfo.body.length - ProtoCommon.TRACKER_QUERY_STORAGE_FETCH_BODY_LEN) / (ProtoCommon.FDFS_IPADDR_SIZE - 1);
-			
-			ip_addr = new String(pkgInfo.body, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN, ProtoCommon.FDFS_IPADDR_SIZE-1).trim();
-			int offset = ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + ProtoCommon.FDFS_IPADDR_SIZE - 1;
-			
-			port = (int)ProtoCommon.buff2long(pkgInfo.body, offset);
-	    offset += ProtoCommon.FDFS_PROTO_PKG_LEN_SIZE;
-	    
-	    ServerInfo[] servers = new ServerInfo[server_count];
-	    servers[0] = new ServerInfo(ip_addr, port);
-	    for (int i=1; i<server_count; i++)
-	    {
-	    	servers[i] = new ServerInfo(new String(pkgInfo.body, offset, ProtoCommon.FDFS_IPADDR_SIZE-1).trim(), port);
-	    	offset += ProtoCommon.FDFS_IPADDR_SIZE - 1;
-	    }
-	
-			return servers;
-		}
-		catch(IOException ex)
-		{
-			if (!bNewConnection)
-			{
-				try
-				{
-					trackerServer.close();
-				}
-				catch(IOException ex1)
-				{
-					ex1.printStackTrace();
-				}
-			}
-			
-			throw ex;
-		}
-		finally
-		{
-			if (bNewConnection)
-			{
-				try
-				{
-					trackerServer.close();
-				}
-				catch(IOException ex1)
-				{
-					ex1.printStackTrace();
-				}
-			}
-		}
-	}
-	
-	/**
-	* query storage server to download file
-	* @param trackerServer the tracker server
-	*	@param file_id the file id(including group name and filename)
-	* @return storage server Socket object, return null if fail
-	*/
-	public StorageServer getFetchStorage1(TrackerServer trackerServer, String file_id) throws IOException
-	{
-		String[] parts = new String[2];
-		this.errno = StorageClient1.split_file_id(file_id, parts);
-		if (this.errno != 0)
-		{
-			return null;
-		}
-		
-		return this.getFetchStorage(trackerServer, parts[0], parts[1]);
-	}
-	
-	/**
-	* get storage servers to download file
-	* @param trackerServer the tracker server
-	*	@param file_id the file id(including group name and filename)
-	* @return storage servers, return null if fail
-	*/
-	public ServerInfo[] getFetchStorages1(TrackerServer trackerServer, String file_id) throws IOException
-	{
-		String[] parts = new String[2];
-		this.errno = StorageClient1.split_file_id(file_id, parts);
-		if (this.errno != 0)
-		{
-			return null;
-		}
-		
-		return this.getFetchStorages(trackerServer, parts[0], parts[1]);
-	}
-	
-	/**
-	* list groups
-	* @param trackerServer the tracker server
-	* @return group stat array, return null if fail
-	*/
-	public StructGroupStat[] listGroups(TrackerServer trackerServer) throws IOException
-	{
-		byte[] header;
-		String ip_addr;
-		int port;
-		byte cmd;
-		int out_len;
-		boolean bNewConnection;
-		byte store_path;
-		Socket trackerSocket;
-		
-		if (trackerServer == null)
-		{
-			trackerServer = getConnection();
-			if (trackerServer == null)
-			{
-				return null;
-			}
-			bNewConnection = true;
-		}
-		else
-		{
-			bNewConnection = false;
-		}
-
-		trackerSocket = trackerServer.getSocket();
-		OutputStream out = trackerSocket.getOutputStream();
-		
-		try
-		{
-			header = ProtoCommon.packHeader(ProtoCommon.TRACKER_PROTO_CMD_SERVER_LIST_GROUP, 0, (byte)0);
-			out.write(header);
-	
-			ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(trackerSocket.getInputStream(), 
-	                                     ProtoCommon.TRACKER_PROTO_CMD_RESP, -1);
-			this.errno = pkgInfo.errno;
-			if (pkgInfo.errno != 0)
-			{
-				return null;
-			}
-			
-			ProtoStructDecoder<StructGroupStat> decoder = new ProtoStructDecoder<StructGroupStat>();
-			return decoder.decode(pkgInfo.body, StructGroupStat.class, StructGroupStat.getFieldsTotalSize());
-		}
-		catch(IOException ex)
-		{
-			if (!bNewConnection)
-			{
-				try
-				{
-					trackerServer.close();
-				}
-				catch(IOException ex1)
-				{
-					ex1.printStackTrace();
-				}
-			}
-			
-			throw ex;
-		}
-		catch(Exception ex)
-		{
-			ex.printStackTrace();
-			this.errno = ProtoCommon.ERR_NO_EINVAL;
-			return null;
-		}
-		finally
-		{
-			if (bNewConnection)
-			{
-				try
-				{
-					trackerServer.close();
-				}
-				catch(IOException ex1)
-				{
-					ex1.printStackTrace();
-				}
-			}
-		}
-	}
-
-	/**
-	* query storage server stat info of the group
-	* @param trackerServer the tracker server
-	*	@param groupName the group name of storage server
-	* @return storage server stat array, return null if fail
-	*/
-	public StructStorageStat[] listStorages(TrackerServer trackerServer, String groupName) throws IOException
-	{
-		final String storageIpAddr = null;
-		return this.listStorages(trackerServer, groupName, storageIpAddr);
-	}
-	
-	/**
-	* query storage server stat info of the group
-	* @param trackerServer the tracker server
-	*	@param groupName the group name of storage server
-	* @param storageIpAddr the storage server ip address, can be null or empty
-	* @return storage server stat array, return null if fail
-	*/
-	public StructStorageStat[] listStorages(TrackerServer trackerServer, 
-			String groupName, String storageIpAddr) throws IOException
-	{
-		byte[] header;
-		byte[] bGroupName;
-		byte[] bs;
-		int len;
-		boolean bNewConnection;
-		Socket trackerSocket;
-		
-		if (trackerServer == null)
-		{
-			trackerServer = getConnection();
-			if (trackerServer == null)
-			{
-				return null;
-			}
-			bNewConnection = true;
-		}
-		else
-		{
-			bNewConnection = false;
-		}
-		trackerSocket = trackerServer.getSocket();
-		OutputStream out = trackerSocket.getOutputStream();
-		
-		try
-		{
-			bs = groupName.getBytes(ClientGlobal.g_charset);
-			bGroupName = new byte[ProtoCommon.FDFS_GROUP_NAME_MAX_LEN];
-			
-			if (bs.length <= ProtoCommon.FDFS_GROUP_NAME_MAX_LEN)
-			{
-				len = bs.length;
-			}
-			else
-			{
-				len = ProtoCommon.FDFS_GROUP_NAME_MAX_LEN;
-			}
-			Arrays.fill(bGroupName, (byte)0);
-			System.arraycopy(bs, 0, bGroupName, 0, len);
-			
-			int ipAddrLen;
-			byte[] bIpAddr;
-			if (storageIpAddr != null && storageIpAddr.length() > 0)
-			{
-				bIpAddr = storageIpAddr.getBytes(ClientGlobal.g_charset);
-				if (bIpAddr.length < ProtoCommon.FDFS_IPADDR_SIZE)
-				{
-					ipAddrLen = bIpAddr.length;
-				}
-				else
-				{
-					ipAddrLen = ProtoCommon.FDFS_IPADDR_SIZE - 1;
-				}
-			}
-			else
-			{
-				bIpAddr = null;
-				ipAddrLen = 0;
-			}
-			
-			header = ProtoCommon.packHeader(ProtoCommon.TRACKER_PROTO_CMD_SERVER_LIST_STORAGE, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + ipAddrLen, (byte)0);
-			byte[] wholePkg = new byte[header.length + bGroupName.length + ipAddrLen];
-			System.arraycopy(header, 0, wholePkg, 0, header.length);
-			System.arraycopy(bGroupName, 0, wholePkg, header.length, bGroupName.length);
-			if (ipAddrLen > 0)
-			{
-				System.arraycopy(bIpAddr, 0, wholePkg, header.length + bGroupName.length, ipAddrLen);
-			}
-			out.write(wholePkg);
-			
-			ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(trackerSocket.getInputStream(), 
-	                                     ProtoCommon.TRACKER_PROTO_CMD_RESP, -1);
-			this.errno = pkgInfo.errno;
-			if (pkgInfo.errno != 0)
-			{
-				return null;
-			}
-			
-			ProtoStructDecoder<StructStorageStat> decoder = new ProtoStructDecoder<StructStorageStat>();
-			return decoder.decode(pkgInfo.body, StructStorageStat.class, StructStorageStat.getFieldsTotalSize());
-		}
-		catch(IOException ex)
-		{
-			if (!bNewConnection)
-			{
-				try
-				{
-					trackerServer.close();
-				}
-				catch(IOException ex1)
-				{
-					ex1.printStackTrace();
-				}
-			}
-			
-			throw ex;
-		}
-		catch(Exception ex)
-		{
-			ex.printStackTrace();
-			this.errno = ProtoCommon.ERR_NO_EINVAL;
-			return null;
-		}
-		finally
-		{
-			if (bNewConnection)
-			{
-				try
-				{
-					trackerServer.close();
-				}
-				catch(IOException ex1)
-				{
-					ex1.printStackTrace();
-				}
-			}
-		}
-	}
-
-	/**
-	* delete a storage server from the tracker server
-	* @param trackerServer the connected tracker server
-	*	@param groupName the group name of storage server
-	* @param storageIpAddr the storage server ip address
-	* @return true for success, false for fail
-	*/
-	private boolean deleteStorage(TrackerServer trackerServer, 
-			String groupName, String storageIpAddr) throws IOException
-	{
-		byte[] header;
-		byte[] bGroupName;
-		byte[] bs;
-		int len;
-		Socket trackerSocket;
-		
-		trackerSocket = trackerServer.getSocket();
-		OutputStream out = trackerSocket.getOutputStream();
-		
-		bs = groupName.getBytes(ClientGlobal.g_charset);
-		bGroupName = new byte[ProtoCommon.FDFS_GROUP_NAME_MAX_LEN];
-		
-		if (bs.length <= ProtoCommon.FDFS_GROUP_NAME_MAX_LEN)
-		{
-			len = bs.length;
-		}
-		else
-		{
-			len = ProtoCommon.FDFS_GROUP_NAME_MAX_LEN;
-		}
-		Arrays.fill(bGroupName, (byte)0);
-		System.arraycopy(bs, 0, bGroupName, 0, len);
-		
-		int ipAddrLen;
-		byte[] bIpAddr = storageIpAddr.getBytes(ClientGlobal.g_charset);
-		if (bIpAddr.length < ProtoCommon.FDFS_IPADDR_SIZE)
-		{
-			ipAddrLen = bIpAddr.length;
-		}
-		else
-		{
-			ipAddrLen = ProtoCommon.FDFS_IPADDR_SIZE - 1;
-		}
-
-		header = ProtoCommon.packHeader(ProtoCommon.TRACKER_PROTO_CMD_SERVER_DELETE_STORAGE, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + ipAddrLen, (byte)0);
-		byte[] wholePkg = new byte[header.length + bGroupName.length + ipAddrLen];
-		System.arraycopy(header, 0, wholePkg, 0, header.length);
-		System.arraycopy(bGroupName, 0, wholePkg, header.length, bGroupName.length);
-		System.arraycopy(bIpAddr, 0, wholePkg, header.length + bGroupName.length, ipAddrLen);
-		out.write(wholePkg);
-		
-		ProtoCommon.RecvPackageInfo pkgInfo = ProtoCommon.recvPackage(trackerSocket.getInputStream(), 
-                                     ProtoCommon.TRACKER_PROTO_CMD_RESP, 0);
-		this.errno = pkgInfo.errno;
-		return pkgInfo.errno == 0;
-	}
-
-	/**
-	* delete a storage server from the global FastDFS cluster
-	*	@param groupName the group name of storage server
-	* @param storageIpAddr the storage server ip address
-	* @return true for success, false for fail
-	*/
-	public boolean deleteStorage(String groupName, String storageIpAddr) throws IOException
-	{
-		return this.deleteStorage(ClientGlobal.g_tracker_group, groupName, storageIpAddr);
-	}
-	
-	/**
-	* delete a storage server from the FastDFS cluster
-	* @param trackerGroup the tracker server group
-	*	@param groupName the group name of storage server
-	* @param storageIpAddr the storage server ip address
-	* @return true for success, false for fail
-	*/
-	public boolean deleteStorage(TrackerGroup trackerGroup, 
-			String groupName, String storageIpAddr) throws IOException
-	{
-		int serverIndex;
-		int notFoundCount;
-		TrackerServer trackerServer;
-				
-		notFoundCount = 0;
-		for (serverIndex=0; serverIndex<trackerGroup.tracker_servers.length; serverIndex++)
-		{			
-			try
-			{
-				trackerServer = trackerGroup.getConnection(serverIndex);
-			}
-			catch(IOException ex)
-			{
-		  	ex.printStackTrace(System.err);
-		  	this.errno = ProtoCommon.ECONNREFUSED;
-		  	return false;
-			}
-			
-			try
-			{
-				StructStorageStat[] storageStats = listStorages(trackerServer, groupName, storageIpAddr);
-				if (storageStats == null)
-				{
-					if (this.errno == ProtoCommon.ERR_NO_ENOENT)
-					{
-						notFoundCount++;
-					}
-					else
-					{
-						return false;
-					}
-				}
-				else if (storageStats.length == 0)
-				{
-					notFoundCount++;
-				}
-				else if (storageStats[0].getStatus() == ProtoCommon.FDFS_STORAGE_STATUS_ONLINE || 
-				         storageStats[0].getStatus() == ProtoCommon.FDFS_STORAGE_STATUS_ACTIVE)
-				{
-					this.errno = ProtoCommon.ERR_NO_EBUSY;
-					return false;
-				}
-			}
-			finally
-			{
-				try
-				{
-					trackerServer.close();
-				}
-				catch(IOException ex1)
-				{
-					ex1.printStackTrace();
-				}
-			}
-		}
-				
-		if (notFoundCount == trackerGroup.tracker_servers.length)
-		{
-	  	this.errno = ProtoCommon.ERR_NO_ENOENT;
-	  	return false;
-		}
-
-		notFoundCount = 0;
-		for (serverIndex=0; serverIndex<trackerGroup.tracker_servers.length; serverIndex++)
-		{
-			try
-			{
-				trackerServer = trackerGroup.getConnection(serverIndex);
-			}
-			catch(IOException ex)
-			{
-		  	System.err.println("connect to server " + trackerGroup.tracker_servers[serverIndex].getAddress().getHostAddress() + ":" + trackerGroup.tracker_servers[serverIndex].getPort() + " fail");
-		  	ex.printStackTrace(System.err);
-		  	this.errno = ProtoCommon.ECONNREFUSED;
-		  	return false;
-			}
-			
-			try
-			{
-				if (!this.deleteStorage(trackerServer, groupName, storageIpAddr))
-				{
-					if (this.errno != 0)
-					{
-						if (this.errno == ProtoCommon.ERR_NO_ENOENT)
-						{
-							notFoundCount++;
-						}
-						else if (this.errno != ProtoCommon.ERR_NO_EALREADY)
-						{
-							return false;
-						}
-					}
-				}
-			}
-			finally
-			{
-				try
-				{
-					trackerServer.close();
-				}
-				catch(IOException ex1)
-				{
-					ex1.printStackTrace();
-				}
-			}
-		}
-		
-		if (notFoundCount == trackerGroup.tracker_servers.length)
-		{
-	  	this.errno = ProtoCommon.ERR_NO_ENOENT;
-	  	return false;
-		}
-		
-		if (this.errno == ProtoCommon.ERR_NO_ENOENT)
-		{
-			this.errno = 0;
-		}
-		
-		return this.errno == 0;
-	}
-}

+ 0 - 120
src/main/java/org/csource/fastdfs/TrackerGroup.java

@@ -1,120 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-*/
-
-package org.csource.fastdfs;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-
-/**
-* Tracker server group
-* @author Happy Fish / YuQing
-* @version Version 1.17
-*/
-public class TrackerGroup
-{
-	protected Integer lock;
-	public int tracker_server_index;
-	public InetSocketAddress[] tracker_servers;
-	
-/**
-* Constructor
-* @param tracker_servers tracker servers
-*/
-	public TrackerGroup(InetSocketAddress[] tracker_servers)
-	{
-		this.tracker_servers = tracker_servers;
-		this.lock = new Integer(0);
-		this.tracker_server_index = 0;
-	}
-
-/**
-* return connected tracker server
-* @return connected tracker server, null for fail
-*/
-	public TrackerServer getConnection(int serverIndex) throws IOException
-	{
-		Socket sock = new Socket();
-		sock.setReuseAddress(true);
-		sock.setSoTimeout(ClientGlobal.g_network_timeout);
-		sock.connect(this.tracker_servers[serverIndex], ClientGlobal.g_connect_timeout);
-		return new TrackerServer(sock, this.tracker_servers[serverIndex]);
-	}
-	
-/**
-* return connected tracker server
-* @return connected tracker server, null for fail
-*/
-	public TrackerServer getConnection() throws IOException
-	{
-		int current_index;
-		
-		synchronized(this.lock)
-		{
-			this.tracker_server_index++;
-			if (this.tracker_server_index >= this.tracker_servers.length)
-			{
-				this.tracker_server_index = 0;
-			}
-			
-			current_index = this.tracker_server_index;
-		}
-		
-		try
-		{
-			return this.getConnection(current_index);
-	  }
-	  catch(IOException ex)
-	  {
-	  	System.err.println("connect to server " + this.tracker_servers[current_index].getAddress().getHostAddress() + ":" + this.tracker_servers[current_index].getPort() + " fail");
-	  	ex.printStackTrace(System.err);
-	  }
-	  
-	  for (int i=0; i<this.tracker_servers.length; i++)
-	  {
-	  	if (i == current_index)
-	  	{
-	  		continue;
-	  	}
-	  	
-			try
-			{
-				TrackerServer trackerServer = this.getConnection(i);
-				
-				synchronized(this.lock)
-				{
-					if (this.tracker_server_index == current_index)
-					{
-						this.tracker_server_index = i;
-					}
-				}
-				
-				return trackerServer;
-		  }
-		  catch(IOException ex)
-		  {
-		  	System.err.println("connect to server " + this.tracker_servers[i].getAddress().getHostAddress() + ":" + this.tracker_servers[i].getPort() + " fail");
-		  	ex.printStackTrace(System.err);
-		  }
-	  }
-	  
-	  return null;
-	}
-
-	public Object clone()
-	{
-		InetSocketAddress[] trackerServers = new InetSocketAddress[this.tracker_servers.length];
-		for (int i=0; i<trackerServers.length; i++)
-		{
-			trackerServers[i] = new InetSocketAddress(this.tracker_servers[i].getAddress().getHostAddress(), this.tracker_servers[i].getPort());
-		}
-		
-		return new TrackerGroup(trackerServers);
-	}
-}

+ 0 - 90
src/main/java/org/csource/fastdfs/TrackerServer.java

@@ -1,90 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-*/
-
-package org.csource.fastdfs;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-
-/**
-* Tracker Server Info
-* @author Happy Fish / YuQing
-* @version Version 1.11
-*/
-public class TrackerServer
-{
-	protected Socket sock;
-	protected InetSocketAddress inetSockAddr;
-	
-/**
-* Constructor
-* @param sock Socket of server
-* @param inetSockAddr the server info
-*/
-	public TrackerServer(Socket sock, InetSocketAddress inetSockAddr)
-	{
-		this.sock = sock;
-		this.inetSockAddr = inetSockAddr;
-	}
-	
-/**
-* get the connected socket
-* @return the socket
-*/
-	public Socket getSocket() throws IOException
-	{
-		if (this.sock == null)
-		{
-			this.sock = ClientGlobal.getSocket(this.inetSockAddr);
-		}
-		
-		return this.sock;
-	}
-	
-/**
-* get the server info
-* @return the server info
-*/
-	public InetSocketAddress getInetSocketAddress()
-	{
-		return this.inetSockAddr;
-	}
-	
-	public OutputStream getOutputStream() throws IOException
-	{
-		return this.sock.getOutputStream();
-	}
-	
-	public InputStream getInputStream() throws IOException
-	{
-		return this.sock.getInputStream();
-	}
-
-	public void close() throws IOException
-	{
-		if (this.sock != null)
-		{
-			try
-			{
-				ProtoCommon.closeSocket(this.sock);
-			}
-			finally
-			{
-				this.sock = null;
-			}
-		}
-	}
-	
-	protected void finalize() throws Throwable
-	{
-		this.close();
-	}
-}

+ 0 - 27
src/main/java/org/csource/fastdfs/UploadCallback.java

@@ -1,27 +0,0 @@
-/**
-* Copyright (C) 2008 Happy Fish / YuQing
-*
-* FastDFS Java Client may be copied only under the terms of the GNU Lesser
-* General Public License (LGPL).
-* Please visit the FastDFS Home Page http://www.csource.org/ for more detail.
-*/
-
-package org.csource.fastdfs;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
-* upload file callback interface
-* @author Happy Fish / YuQing
-* @version Version 1.0
-*/
-public interface UploadCallback
-{
-	/**
-	* send file content callback function, be called only once when the file uploaded
-	* @param out output stream for writing file content
-	* @return 0 success, return none zero(errno) if fail
-	*/
-	public int send(OutputStream out) throws IOException;
-}

+ 0 - 60
src/main/java/org/csource/fastdfs/UploadStream.java

@@ -1,60 +0,0 @@
-package org.csource.fastdfs;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
-* Upload file by stream
-* @author zhouzezhong & Happy Fish / YuQing
-* @version Version 1.11
-*/
-public class UploadStream implements UploadCallback
-{
-	private InputStream inputStream; //input stream for reading
-	private long fileSize = 0;  //size of the uploaded file
-	
-	/** 
-	* constructor
-	* @param inputStream input stream for uploading
-	* @param fileSize size of uploaded file
-	*/
-	public UploadStream(InputStream inputStream, long fileSize)
-	{
-		super();
-		this.inputStream = inputStream;
-		this.fileSize = fileSize;
-	}
-
-	/**
-	* send file content callback function, be called only once when the file uploaded
-	* @param out output stream for writing file content
-	* @return 0 success, return none zero(errno) if fail
-	*/
-	public int send(OutputStream out) throws IOException
-	{
-		long remainBytes = fileSize;
-		byte[] buff = new byte[256 * 1024];
-		int bytes;
-		while(remainBytes > 0)
-		{ 
-			try
-			{
-				if ((bytes=inputStream.read(buff, 0, remainBytes > buff.length ? buff.length : (int)remainBytes)) < 0)
-				{
-					return -1;
-				}
-			}
-			catch(IOException ex)
-			{
-				ex.printStackTrace(); 
-				return -1;
-			}
-			
-			out.write(buff, 0, bytes);
-			remainBytes -= bytes;
-		}
-		
-		return 0;
-	}
-}

+ 1 - 11
src/main/resources/application-dev.yml

@@ -15,14 +15,4 @@ spring:
         testOnBorrow: false
         testOnReturn: false
         poolPreparedStatements: true
-        maxPoolPreparedStatementPerConnectionSize: 20
-# FastDFS 服务配置
-fdfs:
-    network-timeout: 5
-    connect-timeout: 30
-    tracker-server:
-        - 177.77.77.159:22122
-    charset: UTF-8
-    tracker-http-port: 8080
-    anti-steal-token: false
-    secret-key: FastDFS1234567890
+        maxPoolPreparedStatementPerConnectionSize: 20

+ 17 - 6
src/main/resources/application.yml

@@ -5,7 +5,7 @@ server:
         max-threads: 1000
         min-spare-threads: 30
     port: 80
-    #context-path: /renren-fast
+    #servlet-path: /renren-fast
 
 # mysql
 spring:
@@ -21,12 +21,23 @@ spring:
         date-format: yyyy-MM-dd HH:mm:ss
     http:
         multipart:
-        max-file-size: 100MB
-        max-request-size: 100MB
-        enabled: true
-    # 指定静态资源的路径
-    resources:
+            max-file-size: 100MB
+            max-request-size: 100MB
+            enabled: true
+    resources: # 指定静态资源的路径
         static-locations: classpath:/static/,classpath:/views/
+    redis:
+        open: false  # 是否开启redis缓存  true开启   false关闭
+        database: 0
+        host: redis.open.renren.io
+        port: 16379
+        password:       # 密码(默认为空)
+        timeout: 6000  # 连接超时时长(毫秒)
+        pool:
+            max-active: 1000  # 连接池最大连接数(使用负值表示没有限制)
+            max-wait: -1      # 连接池最大阻塞等待时间(使用负值表示没有限制)
+            max-idle: 10      # 连接池中的最大空闲连接
+            min-idle: 5       # 连接池中的最小空闲连接
 
 # Mybatis配置
 mybatis:

+ 2 - 2
src/main/resources/mapper/job/ScheduleJobLogDao.xml

@@ -9,7 +9,7 @@
 	<select id="queryList" resultType="io.renren.modules.job.entity.ScheduleJobLogEntity" >
 		select * from schedule_job_log 
 		<where>
-			<if test="jobId != null">
+			<if test="jobId != null and jobId.trim() != ''">
 				and job_id = #{jobId}
 			</if>
 		</where>
@@ -22,7 +22,7 @@
  	<select id="queryTotal" resultType="int">
 		select count(1) from schedule_job_log 
 		<where>
-			<if test="jobId != null">
+			<if test="jobId != null and jobId.trim() != ''">
 				and job_id = #{jobId}
 			</if>
 		</where>

+ 2 - 2
src/main/resources/mapper/sys/SysConfigDao.xml

@@ -38,8 +38,8 @@
 	</update>
 	
 	<!-- 根据key,查询value -->
-	<select id="queryByKey" parameterType="string" resultType="string">
-		select value from sys_config where `key` = #{key}
+	<select id="queryByKey" parameterType="string" resultType="io.renren.modules.sys.entity.SysConfigEntity">
+		select * from sys_config where `key` = #{key}
 	</select>
 	
 	<delete id="deleteBatch" parameterType="int">

+ 4 - 14
src/main/resources/mapper/sys/SysLogDao.xml

@@ -35,7 +35,8 @@
 			`username`, 
 			`operation`, 
 			`method`, 
-			`params`, 
+			`params`,
+			`time`,
 			`ip`, 
 			`create_date`
 		)
@@ -45,22 +46,11 @@
 			#{operation}, 
 			#{method}, 
 			#{params}, 
-			#{ip}, 
+			#{time},
+			#{ip},
 			#{createDate}
 		)
 	</insert>
-	 
-	<update id="update" parameterType="io.renren.modules.sys.entity.SysLogEntity">
-		update sys_log 
-		<set>
-			<if test="username != null">`username` = #{username}, </if>
-			<if test="operation != null">`operation` = #{operation}, </if>
-			<if test="method != null">`method` = #{method}, </if>
-			<if test="params != null">`params` = #{params}, </if>
-			<if test="ip != null">`ip` = #{ip} </if>
-		</set>
-		where id = #{id}
-	</update>
 	
 	<delete id="delete">
 		delete from sys_log where id = #{value}

+ 9 - 1
src/main/resources/static/js/common.js

@@ -18,7 +18,7 @@ var url = function(name) {
 T.p = url;
 
 //请求前缀
-//var baseURL = "http://demo.open.renren.io/renren-fast/";
+//var baseURL = "http://www.juziku.com/";
 //var baseURL = "/renren-fast/";
 var baseURL = "/";
 
@@ -35,6 +35,9 @@ $.ajaxSetup({
     headers: {
         "token": token
     },
+    xhrFields: {
+	    withCredentials: true
+    },
     complete: function(xhr) {
         //token过期,则跳转到登录页面
         if(xhr.responseJSON.code == 401){
@@ -109,4 +112,9 @@ function getSelectedRows() {
     }
     
     return grid.getGridParam("selarrrow");
+}
+
+//判断是否为空
+function isBlank(value) {
+    return !value || !/\S/.test(value)
 }

+ 31 - 20
src/main/resources/static/js/index.js

@@ -1,20 +1,23 @@
 //生成菜单
 var menuItem = Vue.extend({
-	name: 'menu-item',
-	props:{item:{}},
-	template:[
-	          '<li>',
-	          '<a v-if="item.type === 0" href="javascript:;">',
-	          '<i v-if="item.icon != null" :class="item.icon"></i>',
-	          '<span>{{item.name}}</span>',
-	          '<i class="fa fa-angle-left pull-right"></i>',
-	          '</a>',
-	          '<ul v-if="item.type === 0" class="treeview-menu">',
-	          '<menu-item :item="item" v-for="item in item.list"></menu-item>',
-	          '</ul>',
-	          '<a v-if="item.type === 1" :href="\'#\'+item.url"><i v-if="item.icon != null" :class="item.icon"></i><i v-else class="fa fa-circle-o"></i> {{item.name}}</a>',
-	          '</li>'
-	].join('')
+    name: 'menu-item',
+    props:{item:{},index:0},
+    template:[
+        '<li :class="{active: (item.type===0 && index === 0)}">',
+        '<a v-if="item.type === 0" href="javascript:;">',
+        '<i v-if="item.icon != null" :class="item.icon"></i>',
+        '<span>{{item.name}}</span>',
+        '<i class="fa fa-angle-left pull-right"></i>',
+        '</a>',
+        '<ul v-if="item.type === 0" class="treeview-menu">',
+        '<menu-item :item="item" :index="index" v-for="(item, index) in item.list"></menu-item>',
+        '</ul>',
+        '<a v-if="item.type === 1" :href="\'#\'+item.url">' +
+        '<i v-if="item.icon != null" :class="item.icon"></i>' +
+        '<i v-else class="fa fa-circle-o"></i> {{item.name}}' +
+        '</a>',
+        '</li>'
+    ].join('')
 });
 
 //iframe自适应
@@ -41,7 +44,7 @@ var vm = new Vue({
 	},
 	methods: {
 		getMenuList: function () {
-			$.getJSON(baseURL + "sys/menu/user", function(r){
+			$.getJSON(baseURL + "sys/menu/nav", function(r){
 				vm.menuList = r.menuList;
                 window.permissions = r.permissions;
 			});
@@ -82,10 +85,17 @@ var vm = new Vue({
 			});
 		},
         logout: function () {
-			//删除本地token
-            localStorage.removeItem("token");
-            //跳转到登录页面
-            location.href = baseURL + 'login.html';
+            $.ajax({
+                type: "POST",
+                url: baseURL + "sys/logout",
+                dataType: "json",
+                success: function(r){
+                    //删除本地token
+                    localStorage.removeItem("token");
+                    //跳转到登录页面
+                    location.href = baseURL + 'login.html';
+                }
+            });
         },
         donate: function () {
             layer.open({
@@ -126,6 +136,7 @@ function routerList(router, menuList){
 			    
 			    //导航菜单展开
 			    $(".treeview-menu li").removeClass("active");
+                $(".sidebar-menu li").removeClass("active");
 			    $("a[href='"+url+"']").parents("li").addClass("active");
 			    
 			    vm.navTitle = $("a[href='"+url+"']").text();

+ 22 - 2
src/main/resources/static/js/modules/job/schedule.js

@@ -73,7 +73,11 @@ var vm = new Vue({
 				vm.schedule = r.schedule;
 			});
 		},
-		saveOrUpdate: function (event) {
+		saveOrUpdate: function () {
+            if(vm.validator()){
+                return ;
+            }
+
 			var url = vm.schedule.jobId == null ? "sys/schedule/save" : "sys/schedule/update";
 			$.ajax({
 				type: "POST",
@@ -194,6 +198,22 @@ var vm = new Vue({
                 postData:{'beanName': vm.q.beanName},
                 page:page 
             }).trigger("reloadGrid");
-		}
+		},
+        validator: function () {
+            if(isBlank(vm.schedule.beanName)){
+                alert("bean名称不能为空");
+                return true;
+            }
+
+            if(isBlank(vm.schedule.methodName)){
+                alert("方法名称不能为空");
+                return true;
+            }
+
+            if(isBlank(vm.schedule.cronExpression)){
+                alert("cron表达式不能为空");
+                return true;
+            }
+        }
 	}
 });

+ 17 - 2
src/main/resources/static/js/modules/sys/config.js

@@ -66,7 +66,7 @@ var vm = new Vue({
                 vm.config = r.config;
             });
 		},
-		del: function (event) {
+		del: function () {
 			var ids = getSelectedRows();
 			if(ids == null){
 				return ;
@@ -91,6 +91,10 @@ var vm = new Vue({
 			});
 		},
 		saveOrUpdate: function () {
+            if(vm.validator()){
+				return ;
+			}
+
 			var url = vm.config.id == null ? "sys/config/save" : "sys/config/update";
 			$.ajax({
 				type: "POST",
@@ -115,6 +119,17 @@ var vm = new Vue({
                 postData:{'key': vm.q.key},
                 page:page
             }).trigger("reloadGrid");
-		}
+		},
+		validator: function () {
+			if(isBlank(vm.config.key)){
+				alert("参数名不能为空");
+				return true;
+			}
+
+            if(isBlank(vm.config.value)){
+                alert("参数值不能为空");
+                return true;
+            }
+        }
 	}
 });

+ 0 - 61
src/main/resources/static/js/modules/sys/generator.js

@@ -1,61 +0,0 @@
-$(function () {
-    $("#jqGrid").jqGrid({
-        url: baseURL + 'sys/generator/list',
-        datatype: "json",
-        colModel: [			
-			{ label: '表名', name: 'tableName', width: 100, key: true },
-			{ label: 'Engine', name: 'engine', width: 70},
-			{ label: '表备注', name: 'tableComment', width: 100 },
-			{ label: '创建时间', name: 'createTime', width: 100 }
-        ],
-		viewrecords: true,
-        height: 385,
-        rowNum: 10,
-		rowList : [10,30,50,100,200],
-        rownumbers: true, 
-        rownumWidth: 25, 
-        autowidth:true,
-        multiselect: true,
-        pager: "#jqGridPager",
-        jsonReader : {
-            root: "page.list",
-            page: "page.currPage",
-            total: "page.totalPage",
-            records: "page.totalCount"
-        },
-        prmNames : {
-            page:"page", 
-            rows:"limit", 
-            order: "order"
-        },
-        gridComplete:function(){
-        	//隐藏grid底部滚动条
-        	$("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" }); 
-        }
-    });
-});
-
-var vm = new Vue({
-	el:'#rrapp',
-	data:{
-		q:{
-			tableName: null
-		}
-	},
-	methods: {
-		query: function () {
-			$("#jqGrid").jqGrid('setGridParam',{ 
-                postData:{'tableName': vm.q.tableName},
-                page:1 
-            }).trigger("reloadGrid");
-		},
-		generator: function() {
-			var tableNames = getSelectedRows();
-			if(tableNames == null){
-				return ;
-			}
-			location.href = baseURL + "sys/generator/code?tables=" + JSON.stringify(tableNames);
-		}
-	}
-});
-

+ 2 - 1
src/main/resources/static/js/modules/sys/log.js

@@ -7,7 +7,8 @@ $(function () {
 			{ label: '用户名', name: 'username', width: 50 }, 			
 			{ label: '用户操作', name: 'operation', width: 70 }, 			
 			{ label: '请求方法', name: 'method', width: 150 }, 			
-			{ label: '请求参数', name: 'params', width: 80 }, 			
+			{ label: '请求参数', name: 'params', width: 80 },
+            { label: '执行时长(毫秒)', name: 'time', width: 80 },
 			{ label: 'IP地址', name: 'ip', width: 70 }, 			
 			{ label: '创建时间', name: 'createDate', width: 90 }			
         ],

+ 17 - 1
src/main/resources/static/js/modules/sys/menu.js

@@ -79,7 +79,11 @@ var vm = new Vue({
                 });
             });
         },
-        saveOrUpdate: function (event) {
+        saveOrUpdate: function () {
+            if(vm.validator()){
+                return ;
+            }
+
             var url = vm.menu.menuId == null ? "sys/menu/save" : "sys/menu/update";
             $.ajax({
                 type: "POST",
@@ -121,6 +125,18 @@ var vm = new Vue({
         reload: function () {
             vm.showList = true;
             Menu.table.refresh();
+        },
+        validator: function () {
+            if(isBlank(vm.menu.name)){
+                alert("菜单名称不能为空");
+                return true;
+            }
+
+            //菜单
+            if(vm.menu.type === 1 && isBlank(vm.menu.url)){
+                alert("菜单URL不能为空");
+                return true;
+            }
         }
     }
 });

+ 13 - 3
src/main/resources/static/js/modules/sys/role.js

@@ -121,6 +121,10 @@ var vm = new Vue({
     		});
 		},
 		saveOrUpdate: function () {
+            if(vm.validator()){
+                return ;
+            }
+
 			//获取选择的菜单
 			var nodes = ztree.getCheckedNodes(true);
 			var menuIdList = new Array();
@@ -148,8 +152,8 @@ var vm = new Vue({
 		},
 		getMenuTree: function(roleId) {
 			//加载菜单树
-			$.get(baseURL + "sys/menu/perms", function(r){
-				ztree = $.fn.zTree.init($("#menuTree"), setting, r.menuList);
+			$.get(baseURL + "sys/menu/list", function(r){
+				ztree = $.fn.zTree.init($("#menuTree"), setting, r);
 				//展开所有节点
 				ztree.expandAll(true);
 				
@@ -165,6 +169,12 @@ var vm = new Vue({
                 postData:{'roleName': vm.q.roleName},
                 page:page
             }).trigger("reloadGrid");
-		}
+		},
+        validator: function () {
+            if(isBlank(vm.role.roleName)){
+                alert("角色名不能为空");
+                return true;
+            }
+        }
 	}
 });

+ 26 - 1
src/main/resources/static/js/modules/sys/user.js

@@ -106,6 +106,10 @@ var vm = new Vue({
 			});
 		},
 		saveOrUpdate: function () {
+            if(vm.validator()){
+                return ;
+            }
+
 			var url = vm.user.userId == null ? "sys/user/save" : "sys/user/update";
 			$.ajax({
 				type: "POST",
@@ -141,6 +145,27 @@ var vm = new Vue({
                 postData:{'username': vm.q.username},
                 page:page
             }).trigger("reloadGrid");
-		}
+		},
+        validator: function () {
+            if(isBlank(vm.user.username)){
+                alert("用户名不能为空");
+                return true;
+            }
+
+            if(vm.user.userId == null && isBlank(vm.user.password)){
+                alert("密码不能为空");
+                return true;
+            }
+
+            if(isBlank(vm.user.email)){
+                alert("邮箱不能为空");
+                return true;
+            }
+
+            if(!validator.isEmail(vm.user.email)){
+                alert("邮箱格式不正确");
+                return true;
+			}
+        }
 	}
 });

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1305 - 0
src/main/resources/static/libs/validator.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 23 - 0
src/main/resources/static/libs/validator.min.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 0
src/main/resources/static/swagger/css/print.css


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 0
src/main/resources/static/swagger/css/reset.css


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 0
src/main/resources/static/swagger/css/screen.css


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 0
src/main/resources/static/swagger/css/style.css


+ 0 - 0
src/main/resources/static/swagger/css/typography.css


BIN
src/main/resources/static/swagger/favicon-16x16.png


BIN
src/main/resources/static/swagger/favicon-32x32.png


BIN
src/main/resources/static/swagger/fonts/DroidSans-Bold.ttf


BIN
src/main/resources/static/swagger/fonts/DroidSans.ttf


BIN
src/main/resources/static/swagger/images/collapse.gif


BIN
src/main/resources/static/swagger/images/expand.gif


BIN
src/main/resources/static/swagger/images/explorer_icons.png


BIN
src/main/resources/static/swagger/images/favicon-16x16.png


BIN
src/main/resources/static/swagger/images/favicon-32x32.png


BIN
src/main/resources/static/swagger/images/favicon.ico


BIN
src/main/resources/static/swagger/images/logo_small.png


BIN
src/main/resources/static/swagger/images/pet_store_api.png


BIN
src/main/resources/static/swagger/images/throbber.gif


BIN
src/main/resources/static/swagger/images/wordnik_api.png


+ 107 - 0
src/main/resources/static/swagger/index.html

@@ -0,0 +1,107 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="UTF-8">
+  <meta http-equiv="x-ua-compatible" content="IE=edge">
+  <title>接口文档 - 人人开源</title>
+  <link rel="icon" type="image/png" href="/favicon.ico" />
+  <link href='css/typography.css' media='screen' rel='stylesheet' type='text/css'/>
+  <link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/>
+  <link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
+  <link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/>
+  <link href='css/print.css' media='print' rel='stylesheet' type='text/css'/>
+
+  <script src='lib/object-assign-pollyfill.js' type='text/javascript'></script>
+  <script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script>
+  <script src='lib/jquery.slideto.min.js' type='text/javascript'></script>
+  <script src='lib/jquery.wiggle.min.js' type='text/javascript'></script>
+  <script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script>
+  <script src='lib/handlebars-4.0.5.js' type='text/javascript'></script>
+  <script src='lib/lodash.min.js' type='text/javascript'></script>
+  <script src='lib/backbone-min.js' type='text/javascript'></script>
+  <script src='swagger-ui.js' type='text/javascript'></script>
+  <script src='lib/highlight.9.1.0.pack.js' type='text/javascript'></script>
+  <script src='lib/highlight.9.1.0.pack_extended.js' type='text/javascript'></script>
+  <script src='lib/jsoneditor.min.js' type='text/javascript'></script>
+  <script src='lib/marked.js' type='text/javascript'></script>
+  <script src='lib/swagger-oauth.js' type='text/javascript'></script>
+
+  <!-- Some basic translations -->
+  <script src='lang/translator.js' type='text/javascript'></script>
+  <script src='lang/zh-cn.js' type='text/javascript'></script>
+
+  <script type="text/javascript">
+    $(function () {
+      var url = window.location.search.match(/url=([^&]+)/);
+      if (url && url.length > 1) {
+        url = decodeURIComponent(url[1]);
+      } else {
+        //url = "http://petstore.swagger.io/v2/swagger.json";
+          url = "../index.yaml";
+      }
+
+      hljs.configure({
+        highlightSizeThreshold: 5000
+      });
+
+      // Pre load translate...
+      if(window.SwaggerTranslator) {
+        window.SwaggerTranslator.translate();
+      }
+      window.swaggerUi = new SwaggerUi({
+        url: url,
+        dom_id: "swagger-ui-container",
+        supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
+        onComplete: function(swaggerApi, swaggerUi){
+          if(typeof initOAuth == "function") {
+            initOAuth({
+              clientId: "your-client-id",
+              clientSecret: "your-client-secret-if-required",
+              realm: "your-realms",
+              appName: "your-app-name",
+              scopeSeparator: " ",
+              additionalQueryStringParams: {}
+            });
+          }
+
+          if(window.SwaggerTranslator) {
+            window.SwaggerTranslator.translate();
+          }
+        },
+        onFailure: function(data) {
+          log("Unable to Load SwaggerUI");
+        },
+        docExpansion: "none",
+        jsonEditor: false,
+        defaultModelRendering: 'schema',
+        showRequestHeaders: false,
+        showOperationIds: false
+      });
+
+      window.swaggerUi.load();
+
+      function log() {
+        if ('console' in window) {
+          console.log.apply(console, arguments);
+        }
+      }
+  });
+  </script>
+</head>
+
+<body class="swagger-section">
+<div id='header'>
+  <div class="swagger-ui-wrap">
+    <a id="logo" href="http://swagger.io"><img class="logo__img" alt="swagger" height="30" width="30" src="images/logo_small.png" /><span class="logo__title">swagger</span></a>
+    <form id='api_selector'>
+      <div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
+      <div id='auth_container'></div>
+      <div class='input'><a id="explore" class="header__btn" href="#" data-sw-translate>Explore</a></div>
+    </form>
+  </div>
+</div>
+
+<div id="message-bar" class="swagger-ui-wrap" data-sw-translate>&nbsp;</div>
+<div id="swagger-ui-container" class="swagger-ui-wrap"></div>
+</body>
+</html>

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1648 - 0
src/main/resources/static/swagger/index.yaml


+ 56 - 0
src/main/resources/static/swagger/lang/en.js

@@ -0,0 +1,56 @@
+'use strict';
+
+/* jshint quotmark: double */
+window.SwaggerTranslator.learn({
+    "Warning: Deprecated":"Warning: Deprecated",
+    "Implementation Notes":"Implementation Notes",
+    "Response Class":"Response Class",
+    "Status":"Status",
+    "Parameters":"Parameters",
+    "Parameter":"Parameter",
+    "Value":"Value",
+    "Description":"Description",
+    "Parameter Type":"Parameter Type",
+    "Data Type":"Data Type",
+    "Response Messages":"Response Messages",
+    "HTTP Status Code":"HTTP Status Code",
+    "Reason":"Reason",
+    "Response Model":"Response Model",
+    "Request URL":"Request URL",
+    "Response Body":"Response Body",
+    "Response Code":"Response Code",
+    "Response Headers":"Response Headers",
+    "Hide Response":"Hide Response",
+    "Headers":"Headers",
+    "Try it out!":"Try it out!",
+    "Show/Hide":"Show/Hide",
+    "List Operations":"List Operations",
+    "Expand Operations":"Expand Operations",
+    "Raw":"Raw",
+    "can't parse JSON.  Raw result":"can't parse JSON.  Raw result",
+    "Example Value":"Example Value",
+    "Model Schema":"Model Schema",
+    "Model":"Model",
+    "Click to set as parameter value":"Click to set as parameter value",
+    "apply":"apply",
+    "Username":"Username",
+    "Password":"Password",
+    "Terms of service":"Terms of service",
+    "Created by":"Created by",
+    "See more at":"See more at",
+    "Contact the developer":"Contact the developer",
+    "api version":"api version",
+    "Response Content Type":"Response Content Type",
+    "Parameter content type:":"Parameter content type:",
+    "fetching resource":"fetching resource",
+    "fetching resource list":"fetching resource list",
+    "Explore":"Explore",
+    "Show Swagger Petstore Example Apis":"Show Swagger Petstore Example Apis",
+    "Can't read from server.  It may not have the appropriate access-control-origin settings.":"Can't read from server.  It may not have the appropriate access-control-origin settings.",
+    "Please specify the protocol for":"Please specify the protocol for",
+    "Can't read swagger JSON from":"Can't read swagger JSON from",
+    "Finished Loading Resource Information. Rendering Swagger UI":"Finished Loading Resource Information. Rendering Swagger UI",
+    "Unable to read api":"Unable to read api",
+    "from path":"from path",
+    "server returned":"server returned"
+});

+ 39 - 0
src/main/resources/static/swagger/lang/translator.js

@@ -0,0 +1,39 @@
+'use strict';
+
+/**
+ * Translator for documentation pages.
+ *
+ * To enable translation you should include one of language-files in your index.html
+ * after <script src='lang/translator.js' type='text/javascript'></script>.
+ * For example - <script src='lang/ru.js' type='text/javascript'></script>
+ *
+ * If you wish to translate some new texts you should do two things:
+ * 1. Add a new phrase pair ("New Phrase": "New Translation") into your language file (for example lang/ru.js). It will be great if you add it in other language files too.
+ * 2. Mark that text it templates this way <anyHtmlTag data-sw-translate>New Phrase</anyHtmlTag> or <anyHtmlTag data-sw-translate value='New Phrase'/>.
+ * The main thing here is attribute data-sw-translate. Only inner html, title-attribute and value-attribute are going to translate.
+ *
+ */
+window.SwaggerTranslator = {
+
+    _words:[],
+
+    translate: function(sel) {
+      var $this = this;
+      sel = sel || '[data-sw-translate]';
+
+      $(sel).each(function() {
+        $(this).html($this._tryTranslate($(this).html()));
+
+        $(this).val($this._tryTranslate($(this).val()));
+        $(this).attr('title', $this._tryTranslate($(this).attr('title')));
+      });
+    },
+
+    _tryTranslate: function(word) {
+      return this._words[$.trim(word)] !== undefined ? this._words[$.trim(word)] : word;
+    },
+
+    learn: function(wordsMap) {
+      this._words = wordsMap;
+    }
+};

+ 56 - 0
src/main/resources/static/swagger/lang/zh-cn.js

@@ -0,0 +1,56 @@
+'use strict';
+
+/* jshint quotmark: double */
+window.SwaggerTranslator.learn({
+    "Warning: Deprecated":"警告:已过时",
+    "Implementation Notes":"接口备注",
+    "Response Class":"响应类",
+    "Status":"状态",
+    "Parameters":"参数",
+    "Parameter":"参数",
+    "Value":"值",
+    "Description":"描述",
+    "Parameter Type":"参数类型",
+    "Data Type":"数据类型",
+    "Response Messages":"响应消息",
+    "HTTP Status Code":"HTTP状态码",
+    "Reason":"原因",
+    "Response Model":"响应模型",
+    "Request URL":"请求URL",
+    "Response Body":"响应体",
+    "Response Code":"响应码",
+    "Response Headers":"响应头",
+    "Hide Response":"隐藏响应",
+    "Headers":"头",
+    "Try it out!":"试一下!",
+    "Show/Hide":"显示/隐藏",
+    "List Operations":"显示操作",
+    "Expand Operations":"展开操作",
+    "Raw":"原始",
+    "can't parse JSON.  Raw result":"无法解析JSON. 原始结果",
+    "Example Value":"示例",
+    "Click to set as parameter value":"点击设置参数",
+    "Model Schema":"模型架构",
+    "Model":"模型",
+    "apply":"应用",
+    "Username":"用户名",
+    "Password":"密码",
+    "Terms of service":"服务条款",
+    "Created by":"创建者",
+    "See more at":"查看更多:",
+    "Contact the developer":"联系开发者",
+    "api version":"api版本",
+    "Response Content Type":"响应类型",
+    "Parameter content type:":"参数类型:",
+    "fetching resource":"正在获取资源",
+    "fetching resource list":"正在获取资源列表",
+    "Explore":"浏览",
+    "Show Swagger Petstore Example Apis":"显示 Swagger Petstore 示例 Apis",
+    "Can't read from server.  It may not have the appropriate access-control-origin settings.":"无法从服务器读取。可能没有正确设置access-control-origin。",
+    "Please specify the protocol for":"请指定协议:",
+    "Can't read swagger JSON from":"无法读取swagger JSON于",
+    "Finished Loading Resource Information. Rendering Swagger UI":"已加载资源信息。正在渲染Swagger UI",
+    "Unable to read api":"无法读取api",
+    "from path":"从路径",
+    "server returned":"服务器返回"
+});

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 0
src/main/resources/static/swagger/lib/backbone-min.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 0
src/main/resources/static/swagger/lib/es5-shim.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 3 - 0
src/main/resources/static/swagger/lib/handlebars-4.0.5.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 0
src/main/resources/static/swagger/lib/highlight.9.1.0.pack.js


+ 1 - 0
src/main/resources/static/swagger/lib/highlight.9.1.0.pack_extended.js

@@ -0,0 +1 @@
+"use strict";!function(){var h,l;h=hljs.configure,hljs.configure=function(l){var i=l.highlightSizeThreshold;hljs.highlightSizeThreshold=i===+i?i:null,h.call(this,l)},l=hljs.highlightBlock,hljs.highlightBlock=function(h){var i=h.innerHTML,g=hljs.highlightSizeThreshold;(null==g||g>i.length)&&l.call(hljs,h)}}();

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 3 - 0
src/main/resources/static/swagger/lib/jquery-1.8.0.min.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 0
src/main/resources/static/swagger/lib/jquery.ba-bbq.min.js


+ 1 - 0
src/main/resources/static/swagger/lib/jquery.slideto.min.js

@@ -0,0 +1 @@
+!function(i){i.fn.slideto=function(o){return o=i.extend({slide_duration:"slow",highlight_duration:3e3,highlight:!0,highlight_color:"#FFFF99"},o),this.each(function(){obj=i(this),i("body").animate({scrollTop:obj.offset().top},o.slide_duration,function(){o.highlight&&i.ui.version&&obj.effect("highlight",{color:o.highlight_color},o.highlight_duration)})})}}(jQuery);

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 0
src/main/resources/static/swagger/lib/jquery.wiggle.min.js


+ 0 - 0
src/main/resources/static/swagger/lib/js-yaml.min.js


Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä