1 package com.dotmarketing.factories; 2 3 import com.dotmarketing.beans.UserProxy; 4 import com.dotmarketing.db.DotHibernate; 5 import com.dotmarketing.util.Logger; 6 import com.liferay.portal.model.User; 7 8 12 public class UserProxyFactory { 13 14 public static UserProxy getUserProxy(String userId) { 15 if(userId == null){ 16 return null; 17 } 18 UserProxy up = null; 19 try { 20 DotHibernate dh = new DotHibernate(UserProxy.class); 21 dh.setQuery("from user_proxy in class com.dotmarketing.beans.UserProxy where user_id = ?"); 22 dh.setParam(userId); 23 24 up = (UserProxy) dh.load(); 25 } catch (Exception e) { 26 Logger.warn(UserProxyFactory.class, "getUserProxy failed:" + e, e); 27 } 28 29 if (up.getInode() == 0) { 30 up.setUserId(userId); 32 InodeFactory.saveInode(up); 33 } 34 return up; 35 36 } 37 38 public static UserProxy getUserProxy(User user) { 39 40 return getUserProxy(user.getUserId()); 41 42 } 43 44 public static UserProxy getUserProxy(long userProxyInode) 45 { 46 return (UserProxy) InodeFactory.getInode(userProxyInode,UserProxy.class); 47 } 48 49 public static void saveUserProxy(UserProxy userProxy) 50 { 51 InodeFactory.saveInode(userProxy); 52 } 53 } | Popular Tags |