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                            _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    }