1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portal.googleapps;
16  
17  import com.liferay.portal.kernel.util.StringPool;
18  import com.liferay.portal.kernel.xml.Document;
19  import com.liferay.portal.kernel.xml.Element;
20  import com.liferay.portal.kernel.xml.SAXReaderUtil;
21  
22  /**
23   * <a href="GEmailSettingsManagerImpl.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Brian Wing Shun Chan
26   */
27  public class GEmailSettingsManagerImpl
28      extends GBaseManagerImpl implements GEmailSettingsManager {
29  
30      public GEmailSettingsManagerImpl(GoogleApps googleApps) {
31          super(googleApps);
32  
33          GAuthenticator gAuthenticator = googleApps.getGAuthenticator();
34  
35          emailSettingsURL =
36              APPS_URL.concat("/emailsettings/2.0/").concat(
37                  gAuthenticator.getDomain());
38      }
39  
40      public void addSendAs(long userId, String fullName, String emailAddress)
41          throws GoogleAppsException {
42  
43          Document document = SAXReaderUtil.createDocument();
44  
45          Element atomEntryElement = addAtomEntry(document);
46  
47          addAppsProperty(atomEntryElement, "name", fullName);
48          addAppsProperty(atomEntryElement, "address", emailAddress);
49          addAppsProperty(
50              atomEntryElement, "makeDefault", Boolean.TRUE.toString());
51  
52          submitAdd(getEmailSettingsURL(userId).concat("/sendas"), document);
53      }
54  
55      protected String getEmailSettingsURL(long userId) {
56          return emailSettingsURL.concat(StringPool.SLASH).concat(
57              String.valueOf(userId));
58      }
59  
60      protected String emailSettingsURL;
61  
62  }