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.Document;
019    import com.liferay.portal.kernel.xml.Element;
020    import com.liferay.portal.kernel.xml.Namespace;
021    import com.liferay.portal.kernel.xml.QName;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public class GBaseManagerImpl {
027    
028            public static final String APPS_URL = GHelperUtil.APPS_URL;
029    
030            public GBaseManagerImpl(GoogleApps googleApps) {
031                    this.googleApps = googleApps;
032            }
033    
034            protected Element addAppsProperty(
035                    Element parentElement, String name, String value) {
036    
037                    return GHelperUtil.addAppsProperty(parentElement, name, value);
038            }
039    
040            protected Element addAtomCategory(Element parentElement, String type) {
041                    return GHelperUtil.addAtomCategory(parentElement, type);
042            }
043    
044            protected Element addAtomEntry(Document document) {
045                    return GHelperUtil.addAtomEntry(document);
046            }
047    
048            protected Namespace getAppsNamespace() {
049                    return GHelperUtil.getAppsNamespace();
050            }
051    
052            protected QName getAppsQName(String localName) {
053                    return GHelperUtil.getAppsQName(localName);
054            }
055    
056            protected Namespace getAtomNamespace() {
057                    return GHelperUtil.getAtomNamespace();
058            }
059    
060            protected QName getAtomQName(String localName) {
061                    return GHelperUtil.getAtomQName(localName);
062            }
063    
064            protected long getCompanyId() {
065                    GAuthenticator gAuthenticator = googleApps.getGAuthenticator();
066    
067                    return gAuthenticator.getCompanyId();
068            }
069    
070            protected Document getDocument(String url) throws GoogleAppsException {
071                    return GHelperUtil.getDocument(googleApps.getGAuthenticator(), url);
072            }
073    
074            protected String getErrorMessage(Document document) {
075                    return GHelperUtil.getErrorMessage(document);
076            }
077    
078            protected boolean hasError(Document document) {
079                    return GHelperUtil.hasError(document);
080            }
081    
082            protected void submitAdd(String url, Document document)
083                    throws GoogleAppsException {
084    
085                    GHelperUtil.submitAdd(googleApps.getGAuthenticator(), url, document);
086            }
087    
088            protected void submitDelete(String url) throws GoogleAppsException {
089                    GHelperUtil.submitDelete(googleApps.getGAuthenticator(), url);
090            }
091    
092            protected void submitUpdate(String url, Document document)
093                    throws GoogleAppsException {
094    
095                    GHelperUtil.submitUpdate(googleApps.getGAuthenticator(), url, document);
096            }
097    
098            protected GoogleApps googleApps;
099    
100    }