package com.chenyang.nse.bussiness.engine.infa.powercenter961.transferdata;

import com.chenyang.nse.bussiness.engine.infa.basic.xmlbean.FOLDER;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

public class Folderutil {
   public FOLDER getFolder(String foldername, String owner, String shaerd, String group) {
      FOLDER folder = new FOLDER();
      UUID uu = UUID.randomUUID();
      String uuid = uu.toString();
      folder.setUUID(uuid);
      folder.setNAME(foldername);
      folder.setGROUP(group);
      folder.setSHARED(shaerd);
      folder.setOWNER(owner);
      folder.setPERMISSIONS("rwx---r--");
      folder.setDESCRIPTION(foldername);
      return folder;
   }

   public static List<String> getAllFolder(Connection conn) {
      List<String> list = new ArrayList();
      PreparedStatement pstmt = null;
      ResultSet rs = null;

      try {
         String sql = " select subj_name from opb_subject order by subj_name";
         pstmt = conn.prepareStatement(sql);
         rs = pstmt.executeQuery();

         while(rs.next()) {
            list.add(rs.getString(1));
         }
      } catch (SQLException e) {
         e.printStackTrace();
      } finally {
         try {
            rs.close();
            pstmt.close();
            conn.close();
         } catch (SQLException e) {
            e.printStackTrace();
         }

      }

      return list;
   }
}
