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                            if (_log.isWarnEnabled()) {
045                                    _log.warn(e);
046                            }
047                    }
048    
049                    return country;
050            }
051    
052            @Override
053            public Region getRegion() {
054                    Region region = null;
055    
056                    try {
057                            region = RegionServiceUtil.getRegion(getRegionId());
058                    }
059                    catch (Exception e) {
060                            region = new RegionImpl();
061    
062                            if (_log.isWarnEnabled()) {
063                                    _log.warn(e);
064                            }
065                    }
066    
067                    return region;
068            }
069    
070            @Override
071            public ListType getType() {
072                    ListType type = null;
073    
074                    try {
075                            type = ListTypeServiceUtil.getListType(getTypeId());
076                    }
077                    catch (Exception e) {
078                            type = new ListTypeImpl();
079    
080                            if (_log.isWarnEnabled()) {
081                                    _log.warn(e);
082                            }
083                    }
084    
085                    return type;
086            }
087    
088            private static Log _log = LogFactoryUtil.getLog(AddressImpl.class);
089    
090    }