ResourceUtil.java 1.48 KB
package com.topdraw.sohu.utils;

import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

import org.afflatus.utility.DruidUtil;

public class ResourceUtil {
	public static void CreateResourceRecycle(String strFileUrl) {
		Connection writeConnection = null;
		try {
			writeConnection = DruidUtil.getRandomWriteConnection();
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("path", strFileUrl);
			map.put("id", UUID.randomUUID().toString());
			DruidUtil.beginTransaction(writeConnection);
			DruidUtil.save(writeConnection, map, "cm_resource_recycle");
			DruidUtil.commitTransaction(writeConnection);
		} catch(Exception ex) {
			ex.printStackTrace();
		} finally {
			DruidUtil.close(writeConnection);
			writeConnection = null;
		}
	}
	
	public static String getImageKeyByType(int iType) {
		String strType = "normal";
		switch (iType) {
		case 0:
			strType = "thumbnail";
			break;
		case 1:
			strType = "poster";
			break;
		case 2:
			strType = "stills";
			break;
		case 3:
			strType = "icon";
			break;
		case 4:
			strType = "title";
			break;
		case 5:
			strType = "ad";
			break;
		case 6:
			strType = "sketch";
			break;
		case 7:
			strType = "background";
			break;
		case 9:
			strType = "channel";
			break;
		case 10:
			strType = "channel_bw";
			break;
		case 11:
			strType = "channel_logo";
			break;
		case 12:
			strType = "channel_name";
			break;
		case 99:
			strType = "other";
			break;
		}
		return strType;
	}
}