Package com.hdfs.file.bean

Examples of com.hdfs.file.bean.HdfsFile


  public boolean deleteFile(long fileId) {
    // TODO Auto-generated method stub
    Session session = this.getSession();
    try {
      Transaction trans = session.beginTransaction();
      HdfsFile file = new HdfsFile();
      file.setFileId(fileId);
      session.delete(findFile(fileId));

      trans.commit();
      session.close();
      return true;
View Full Code Here


     * session.get(HdfsFile.class, fileId); return file;
     */
    Session session = this.getSession();
    Criteria crit = session.createCriteria(HdfsFile.class);
    crit.add(Restrictions.eq("fileId", fileId));
    HdfsFile file = null;
    try {
      file = (HdfsFile) crit.uniqueResult();
    } catch (Exception e) {
      return null;
    } finally {
View Full Code Here

        if (getUploadType() != 0) { // 加密上传的后续处理
          /*
           * 将加密后的数据密钥保存到数据库中 encryptedDataSecretKey
           * 即更新对应文件下的encrypt_DataKey属性
           */
          HdfsFile hdfsFile = new HdfsFile();
          hdfsFile.setFileId(fileId);

          fileservice.storeEncryptDataKey(fileId,
              encryptedDataSecretKey);

        }
View Full Code Here

          if (getUploadType() != 0) { // 加密上传的后续处理
            /*
             * 将加密后的数据密钥保存到数据库中 encryptedDataSecretKey
             * 即更新对应文件下的encrypt_DataKey属性
             */
            HdfsFile hdfsFile = new HdfsFile();
            hdfsFile.setFileId(fileId);

            fileservice.storeEncryptDataKey(fileId,
                encryptedDataSecretKey);

          }
View Full Code Here

        .listAllFile();
    if (list != null && list.size() > 0) {
      out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
      out.println("<nodes>");
      for (int i = 0; i < list.size(); i++) {
        HdfsFile file = list.get(i);
        out.println("<node file_id='" + file.getFileId()
            + "' parentid='" + file.getParentid()
            + "' hrefAddress='" + file.getFileId() + "' userid='"
            + file.getUserId() + "'>" + file.getFileName()
            + "</node>");
        System.out.println(file.getFileName());
      }
      out.println("</nodes>");
    }
    System.out.println("调用完成");
View Full Code Here

    }// 新建文件的详细路径
    else {
      newfile = parentPath + "/" + name;
    }
    long fileId = pathToId.ParsepathToId(newfile);// hash得出fileid
    HdfsFile hdfsfile = new HdfsFile(fileId, name, parentId, newfile, 0);
    hdfsfile.setUserId(userId);
    hdfsfile.setCreateTime(new Date());
    hdfsfile.setModifiedTime(new Date());

    boolean result = filedao.insertFile(hdfsfile);// 保存文件
    createAction caction = new createAction();
    caction.createDir(newfile);// 操作文件系统
    return result;
View Full Code Here

      newfile = parentPath + "/" + name;
    }

    long fileId = rootid;// hash得出fileid

    HdfsFile hdfsfile = new HdfsFile(fileId, name, parentId, newfile, 0);
    hdfsfile.setUserId(userId);
    hdfsfile.setCreateTime(new Date());
    hdfsfile.setModifiedTime(new Date());

    System.out.println(newfile);
    boolean result = filedao.insertFile(hdfsfile);// 保存文件,即在数据库中保存该文件的信息

    // 在hdfs文件系统创建相应的文件夹
View Full Code Here

  @Override
  public String deleteFile(long fileId, HdfsMemory memory) {
    // TODO Auto-generated method stub
    boolean deletedb = false;
    String result = "";
    HdfsFile file = filedao.findFile(fileId);
    if (filedao.findFile(fileId) == null)
      System.out.println("kongduixiang");// 获得文件的url
    System.out.println("url is :" + file.getFileUrl());
    deleteAction delete = new deleteAction();
    boolean deletehdfs = delete.deleteDirector(file.getFileUrl());
    if (deletehdfs) {
      int delmem = filedao.deleteFilesmem(file.getFileUrl());
      deletedb = filedao.deleteFiles(file.getFileUrl());// 删除数据库中该文件和子文件的记
      // Users user = new Users();
      // System.out.println(hfile.getFileId());
      // int id = (int) file.getUserId();
      // user.setUserId(id);
      // user = userdao.findid(id);
      // HdfsMemory memory = filedao.find(user.getMemoryId());
      // HdfsMemory memory =
      // filedao.getMemory(userdao.find(user).getMemoryId());
      memory.setMemoryused(memory.getMemoryused() - delmem);
      filedao.updateMemory(memory);
    } else {
      return null;
    }
    if (deletedb) {
      System.out.println("the result is " + deletedb);
      result = listFile(file.getParentid(), file.getUserId());
    }
    return result;

  }
View Full Code Here

  public dillResult renameFile(long fileId, String name) {
    boolean dohdfs = false;
    boolean dodelete = false;
    boolean doinsert = false;
    dillResult result = new dillResult();
    HdfsFile file = filedao.findFile(fileId);
    String src = file.getFileUrl();// 源url
    String dst = src.substring(0, src.lastIndexOf("/")) + "/" + name;// 新的url
    System.out.println("the new name is:" + dst);
    renameAction rename = new renameAction();
    try {
      dohdfs = rename.rename(src, dst);// 操作文件系统
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }//
    if (dohdfs) {
      System.out.println("do hdfs success!");
      filedao.deleteFiles(file.getFileUrl());// 删除原来的记录
      dodelete = true;
    }
    if (dodelete) {

      System.out.println("do delete success!");
      long newid = pathToId.ParsepathToId(dst);// 获得新的fileid
      file.setFileId(newid);
      file.setFileName(name);
      file.setFileUrl(dst);
      doinsert = filedao.insertFile(file);// 新增记录
    }
    if (doinsert) {
      System.out.println("do insert success");
      String listfile = listFile(file.getParentid(), file.getUserId());
      result.setWddescjson(listfile);
      result.setUserId(file.getUserId());
      result.setParentid(file.getParentid());
      // result.setFileName(name);
      result.setFileUrl(dst);
      System.out.println("the new name is:" + dst);
    }
View Full Code Here

    return result;
  }

  @Override
  public dillResult listParentFile(long currentId, long userId) {
    HdfsFile file = filedao.findFile(currentId);
    System.out.println();
    if (null == file) {
      System.out.println("是空的!");
      return null;
    }
    dillResult result = new dillResult();
    String listfile = listFile(file.getParentid(), file.getUserId());
    result.setWddescjson(listfile);
    result.setUserId(file.getUserId());
    result.setParentid(file.getParentid());
    result.setFileId(file.getFileId());
    return result;

  }
View Full Code Here

TOP

Related Classes of com.hdfs.file.bean.HdfsFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.