001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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    }