1 22 23 package com.dotmarketing.cms.factories; 24 25 import java.util.List ; 26 27 import org.apache.commons.logging.LogFactory; 28 29 import com.dotmarketing.exception.DotRuntimeException; 30 import com.liferay.counter.ejb.CounterManagerUtil; 31 import com.liferay.portal.NoSuchAddressException; 32 import com.liferay.portal.SystemException; 33 import com.liferay.portal.ejb.AddressUtil; 34 import com.liferay.portal.model.Address; 35 36 43 public class PublicAddressFactory extends AddressUtil{ 44 45 public static List getAddressesByUserId(String p0) throws SystemException { 46 47 48 return findByUserId(p0); 49 50 } 51 52 53 public static Address getAddressById(String p0) throws SystemException { 54 55 try{ 56 return findByPrimaryKey(p0); 57 } 58 catch(NoSuchAddressException nsae){ 59 60 return getInstance(); 61 } 62 catch(SystemException se){ 63 throw new DotRuntimeException("Can't get Address"); 64 } 65 66 } 67 68 69 70 71 72 73 87 public static Address getInstance(){ 88 String addressId = null; 89 try{ 90 addressId = Long.toString(CounterManagerUtil.increment( Address.class.getName() )); 91 92 } 93 catch(SystemException e){ 94 throw new DotRuntimeException("Can't get a counter"); 95 } 96 return new Address(addressId); 97 } 98 99 100 public static void save(Address a) { 101 102 try{ 103 update(a); 104 } 105 catch(SystemException e){ 106 throw new DotRuntimeException("Can't save the address"); 107 } 108 109 } 110 public static void delete(Address a ){ 111 try{ 112 remove(a.getAddressId()); 113 114 } 115 catch (NoSuchAddressException e) { 116 LogFactory.getLog(PublicAddressFactory.class).error("No such Address to delete"); 117 } 118 catch (SystemException e) { 119 LogFactory.getLog(PublicAddressFactory.class).error("Deleting Address", e); 120 } 121 122 123 124 } 125 126 127 128 129 } | Popular Tags |