001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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    }