001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.log.Log;
018    import com.liferay.portal.kernel.log.LogFactoryUtil;
019    import com.liferay.portal.model.Address;
020    import com.liferay.portal.model.Country;
021    import com.liferay.portal.model.ListType;
022    import com.liferay.portal.model.Region;
023    import com.liferay.portal.service.CountryServiceUtil;
024    import com.liferay.portal.service.ListTypeServiceUtil;
025    import com.liferay.portal.service.RegionServiceUtil;
026    
027    /**
028     * @author Brian Wing Shun Chan
029     */
030    public class AddressImpl extends AddressModelImpl implements Address {
031    
032            public AddressImpl() {
033            }
034    
035            public Region getRegion() {
036                    Region region = null;
037    
038                    try {
039                            region = RegionServiceUtil.getRegion(getRegionId());
040                    }
041                    catch (Exception e) {
042                            region = new RegionImpl();
043    
044                            _log.warn(e);
045                    }
046    
047                    return region;
048            }
049    
050            public Country getCountry() {
051                    Country country = null;
052    
053                    try {
054                            country = CountryServiceUtil.getCountry(getCountryId());
055                    }
056                    catch (Exception e) {
057                            country = new CountryImpl();
058    
059                            _log.warn(e);
060                    }
061    
062                    return country;
063            }
064    
065            public ListType getType() {
066                    ListType type = null;
067    
068                    try {
069                            type = ListTypeServiceUtil.getListType(getTypeId());
070                    }
071                    catch (Exception e) {
072                            type = new ListTypeImpl();
073    
074                            _log.warn(e);
075                    }
076    
077                    return type;
078            }
079    
080            private static Log _log = LogFactoryUtil.getLog(AddressImpl.class);
081    
082    }