photo.setYear(cal.get(Calendar.YEAR));
photo.setMonth((cal.get(Calendar.MONTH)+1));
photo.setDate(cal.get(Calendar.DATE));
photo.setCreateTime(cal.getTime());
Session ssn = getSession();
try{
beginTransaction();
//��site���������ռ�
int photo_site = DLOG4JUtils.sizeInKbytes(photo.getPhotoInfo().getSize());
photo.getSite().getCapacity().incPhotoUsed(photo_site);
//���ಾ����Ƭ��
album.setPhotoCount(album.getPhotoCount()+1);
if(cover)
album.setCover(photo);
//�ݹ����и��ಾ
AlbumBean parent = album.getParent();
int deep = 0;
do{
if(parent == null)
break;
deep ++;
parent.incPhotoCount(1);
parent = parent.getParent();
}while(deep < 10);//������ʮ���ಾ
photo.getUser().getCount().incPhotoCount(1);
ssn.save(photo);
if (album.getType() == AlbumBean.TYPE_PUBLIC
&& photo.getStatus() != PhotoBean.STATUS_PRIVATE) {
List tags = photo.getKeywords();
if(tags!=null && tags.size()>0){
int tag_count = 0;
for(int i=0;i<tags.size();i++){
if(tag_count>=MAX_TAG_COUNT)
break;
String tag_name = (String)tags.get(i);
if(tag_name.getBytes().length > MAX_TAG_LENGTH)
continue;
TagBean tag = new TagBean();
tag.setSite(photo.getSite());
tag.setRefId(photo.getId());
tag.setRefType(DiaryBean.TYPE_PHOTO);
tag.setName(tag_name);
ssn.save(tag);
tag_count ++;
}
}
}