云存储文件列表功能_第1页
云存储文件列表功能_第2页
云存储文件列表功能_第3页
云存储文件列表功能_第4页
云存储文件列表功能_第5页
已阅读5页,还剩14页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

云存储文件列表功能目录技术原理实现步骤功能描述功能测试2技术原理3(1)视图层:展示所有文件信息(2)控制层:接收视图层的消息,向服务层发送文件列表参数,并将服务层返回的结果发送到视图层(3)服务层:获取当前账号的云存储对象,将获取到的云存储对象转换为本地模拟文件系统功能描述4实现步骤5在cn/edu/sict/cloud/storage/sh/bean文件夹下创建FileBean.javapublic

classFileBean{private

boolean

isdirectory;//是否是目录private

boolean

haschild;//是否有子文件夹privateStringname;//文件名称privateStringpath;//文件路径privateStringlength;//文件大小privateStringlastmodified;//最后修改时间privateStringfilepath;//如果是文件,存放文件的临时路径public

booleanisHaschild(){return

haschild;}public

voidsetHaschild(boolean

haschild){this.haschild=haschild;}public

booleanisIsdirectory(){return

isdirectory;}public

voidsetIsdirectory(boolean

isdirectory){this.isdirectory=isdirectory;}实现步骤6在cn/edu/sict/cloud/storage/sh/bean文件夹下创建FileBean.javapublicStringgetFilepath(){return

filepath;}public

voidsetFilepath(Stringfilepath){this.filepath=filepath;}publicStringgetLength(){return

length;}public

voidsetLength(long

length){this.length=UtilTools.convertFileSize(length);}publicStringgetLastmodified(){return

lastmodified;}public

voidsetLastmodified(Stringlastmodified){this.lastmodified=lastmodified;}publicStringgetName(){return

name;}public

voidsetName(Stringname){=name;}publicStringgetPath(){return

path;}public

voidsetPath(Stringpath){this.path=path;}}实现步骤7在cn/edu/sict/cloud/storage/sh/文件夹下swiftDFS.java添加如下代码publicListgetFile(Stringrpath){Mapmappath=this.getSplitPath(rpath);StringrootPath=mappath.get("rootPath").toString();Stringpath=mappath.get("path").toString();List<?extendsSwiftObject>objs=this.list(rootPath,path);Listlist=newArrayList();for(SwiftObjectobj:objs){FileBeanfb=newFileBean();StringfilePath=obj.getName();fb.setPath(filePath);fb.setName(this.getName(filePath));boolean

flag=this.isDirectory(filePath);fb.setIsdirectory(flag);实现步骤8在cn/edu/sict/cloud/storage/sh/文件夹下swiftDFS.java添加如下代码if(!flag){ fb.setLength(obj.getSizeInBytes());}fb.setLastmodified(DateUtil.cstToHMS(obj.getLastModified()));list.add(fb);} return

list;}实现步骤9在cn/edu/sict/cloud/storage/sh/文件夹下swiftDFS.java添加如下代码privateMap<String,String>getSplitPath(Stringpath){String[]strPath=path.split("/");StringrootPath="";path="";for(int

i=0;i<strPath.length;i++){if(i==0){rootPath=strPath[0];}else{if(i==strPath.length-1){if(strPath[i].contains(".")){path+=strPath[i];}else{path+=strPath[i]+"/";}实现步骤10在cn/edu/sict/cloud/storage/sh/文件夹下swiftDFS.java添加如下代码}else{path+=strPath[i]+"/";}}}Mapmap=newHashMap();map.put("rootPath",rootPath);map.put("path",path);return

map;}实现步骤11在cn/edu/sict/cloud/storage/util文件夹下新建ComparatorFile.javapublic

classComparatorFileimplementsComparator<FileBean>{publicComparatorFile(){}public

intcompare(FileBeanf1,FileBeanf2){boolean

f1dir=f1.isIsdirectory();boolean

f2dir=f2.isIsdirectory();if(f1dir&&f2dir){return0;}else

if(!f1dir&&f2dir){return1;}else

if(f1dir&&!f2dir){return-1;}else

if(!f1dir&&!f2dir){return0;}return0;}}实现步骤12在cn/edu/sict/cloud/storage/service/SwiftStorageService.java添加如下代码publicListgetAllStoredList(Stringusername,Stringpath){SwiftDFSswiftdfs=newSwiftDFS();Stringup=null;up=username+"/"+path;Listlist=swiftdfs.getFile(up);ComparatorFilecomparator=newComparatorFile();

if(!list.isEmpty()){

synchronized(list){Collections.sort(list,comparator);

}

}return

list;}实现步骤13在cn/edu/sict/cloud/storage/Web/StorageController.java添加如下代码@RequestMapping("/home")publicModelAndViewhome(HttpServletRequestrequest,HttpServletResponseresponse,Stringpath){ModelAndViewview=newModelAndView();Useruser=getSessionUser(request);path=UtilTools.converStr(path);Listlist=storage.getAllStoredList(user.getUsername(),path);view.addObject("path",path);view.addObject("search","false");view.addObject("list",list);view.setViewName("/main");view.addObject("type",0);return

view;}实现步骤14在main.jsp的table标签中添加如下代码<tbodyid="tab"><c:forEachvar="fb"items="${list}"><tr><tdstyle="top:-6px;position:relative;left:13px;"><labelclass="checkboxtable-checkboxposition"for="checkbox1"><spanclass="iconsmain-icons">

<spanclass="first-iconfui-checkbox-unchecked"></span>

<spanclass="second-iconfui-checkbox-checked"></span></span>

<inputtype="checkbox"name='check'class="main-tabinput"onclick="show()"></label></td><td><spanstyle="display:block"><c:iftest="${fb.isdirectory==true}">实现步骤15在main.jsp的table标签中添加如下代码<imgsrc="assets/images/0.png"class="objimg"><a

href="home.action?path=${fb.path}"><inputname="objimg"type="text"style="display:none"value="${}"></c:if>${}<c:iftest="${fb.isdirectory==true}"></a>实现步骤16在main.jsp的table标签中添加如下代码</c:if></span><divclass="edit-name"style="display:none;"><inputclass="box"type="text"value="${}"><aclass="sure"

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论