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.googleapps;
016    
017    import com.liferay.portal.kernel.googleapps.GoogleAppsException;
018    import com.liferay.portal.kernel.xml.Element;
019    
020    import java.util.List;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public abstract class GetNextItems {
026    
027            public GetNextItems(String url, Element atomFeedElement)
028                    throws GoogleAppsException {
029    
030                    List<Element> atomLinkElements = atomFeedElement.elements(
031                            GHelperUtil.getAtomQName("link"));
032    
033                    for (Element atomLinkElement : atomLinkElements) {
034                            String rel = atomLinkElement.attributeValue("rel");
035    
036                            if (rel.equals("next")) {
037                                    String href = atomLinkElement.attributeValue("href");
038    
039                                    if (!href.equals(url)) {
040                                            getNextItems(href);
041                                    }
042    
043                                    break;
044                            }
045                    }
046            }
047    
048            public abstract void getNextItems(String nextURL)
049                    throws GoogleAppsException;
050    
051    }