package org.jerrymouse.cc.site.store.cc;

import org.jerrymouse.cc.site.store.StoreManager;

public class CCStoreManager extends StoreManager {
	private String username;
	CCResourceFileDao ccResourceFileDao = CCResourceFileDao
			.getCCResourceFileDao();

	public CCStoreManager(String username) {
		this.username = username;
	}

	public CCStoreManager() {
	}

	@Override
	public byte[] getBytes(String filename) {
		CCResourceFile ccResourceFile = ccResourceFileDao.get(username,
				filename);
		if (ccResourceFile == null)
			return null;
		return ccResourceFile.getContent();
	}

	@Override
	public void putBytes(String filename, byte[] bytes) {
		CCResourceFile ccResourceFile = new CCResourceFile();
		ccResourceFile.setContent(bytes);
		ccResourceFile.setFilename(filename);
		ccResourceFile.setUsername(username);
		ccResourceFileDao.put(ccResourceFile);
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getUsername() {
		return username;
	}

}
