
package com.platform.controller;


import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import oracle.sql.DATE;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;




import com.base.BaseController;
import com.base.CustomException;
import com.platform.entities.GfsFolderEntity;


import com.platform.entities.VolumeEntity;
import com.platform.glusterfs.VolumeInfo;
import com.platform.entities.VolumeEntity;
import com.platform.glusterfs.VolumeInfo;
import com.platform.service.IGfsService;
import com.platform.utils.Configs;


/**
 * <一句话功能简述>
 * <功能详细描述>
 * @author    chen
 * @version   [版本号，2016年9月8日]
 * @see       [相关类/方法]
 * @since     [产品/模块版本]
 */
@Controller

@RequestMapping("")

public class FolderController extends BaseController {
	
	public static Logger log = Configs.DAILY_ROLLING_LOGGER.getLogger(FolderController.class);
	
	@Resource(name = "gfsService")
	private IGfsService gfsService;
	



	@RequestMapping(value="/getAllSubPathByPath", method= RequestMethod.POST)

	public Object getAllSubPathByPath(String path) throws Exception {
		System.out.println(path);
		Object result = null;
		if (null != path && !"".equals(path)) {
			System.out.println(path);
			result = gfsService.getFolder(path);
		}
		return result;
	}
	

	@RequestMapping("/copyFolder")
	public Object copyFolder(String srcpath, String dstPath, String name) throws Exception {
		// -1 :error; -2: the filename is not exists ;-3 :destFolderName ; 1: right 
		int result = 0;
//		int result = gfsService.copyFolder(srcpath, dstPath, name);
		System.out.println(srcpath);
		System.out.println(dstPath);
		String obj = "right";
		
		if (1 != result) {
			obj = "err";
		}
		return obj;
	}

//	/**
//	 * <一句话功能简述> 查询集群中所有的 volume 及其 信息
//	 * <功能详细描述>
//	 * @return
//	 * @throws Exception 
//	 * @see [类、类#方法、类#成员]
//	 */
//	@RequestMapping(value="/volume/list", method= RequestMethod.POST)
//	public Object getVolums() throws Exception{
//		System.out.println("----------------------------------");
//		long a = new Date().getTime();
//		 List<VolumeEntity> result = gfsService.getAllVolumes();
//		 System.out.println("----------------------------------");
//		 System.out.println(new Date().getTime()-a);
//		return result;
//	}
//	
	/**
	 * <一句话功能简述> 查询集群中所有的 volume 及其 信息
	 * <功能详细描述>
	 * @param volumeName "/home/gfs_ftp_point" "/home/v1_point"
	 * @return 
	 * @throws Exception 
	 * @see [类、类#方法、类#成员]
	 */
	
	@RequestMapping(value="/volume/findByName", method= RequestMethod.POST)
	public Object getVolumByName(String volumeName) throws Exception{
		VolumeEntity result = gfsService.getOneVolume(volumeName);
		return result;

	}
	
}
