001    /**
002     * Copyright (c) 2000-2013 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.Country;
020    import com.liferay.portal.model.ListType;
021    import com.liferay.portal.model.Region;
022    import com.liferay.portal.service.CountryServiceUtil;
023    import com.liferay.portal.service.ListTypeServiceUtil;
024    import com.liferay.portal.service.RegionServiceUtil;
025    
026    /**
027     * @author Brian Wing Shun Chan
028     */
029    public class AddressImpl extends AddressBaseImpl {
030    
031            public AddressImpl() {
032            }
033    
034            @Override
035            public Country getCountry() {
036                    Country country = null;
037    
038                    try {
039                            country = CountryServiceUtil.getCountry(getCountryId());
040                    }
041                    catch (Exception e) {
042                            country = new CountryImpl();
043    
044                            _log.warn(e);
045                    }
046    
047                    return country;
048            }
049    
050            @Override
051            public Region getRegion() {
052                    Region region = null;
053    
054                    try {
055                            region = RegionServiceUtil.getRegion(getRegionId());
056                    }
057                    catch (Exception e) {
058                            region = new RegionImpl();
059    
060                            _log.warn(e);
061                    }
062    
063                    return region;
064            }
065    
066            @Override
067            public ListType getType() {
068                    ListType type = null;
069    
070                    try {
071                            type = ListTypeServiceUtil.getListType(getTypeId());
072                    }
073                    catch (Exception e) {
074                            type = new ListTypeImpl();
075    
076                            _log.warn(e);
077                    }
078    
079                    return type;
080            }
081    
082            private static Log _log = LogFactoryUtil.getLog(AddressImpl.class);
083    
084    }