001    /**
002     * Copyright (c) 2000-2011 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.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    }