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.portlet.announcements.model.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.SystemException;
19  import com.liferay.portal.kernel.util.PropsKeys;
20  import com.liferay.portal.model.Group;
21  import com.liferay.portal.model.Organization;
22  import com.liferay.portal.service.GroupLocalServiceUtil;
23  import com.liferay.portal.service.OrganizationLocalServiceUtil;
24  import com.liferay.portal.util.PropsUtil;
25  import com.liferay.portlet.announcements.model.AnnouncementsEntry;
26  
27  /**
28   * <a href="AnnouncementsEntryImpl.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Brian Wing Shun Chan
31   * @author Wesley Gong
32   */
33  public class AnnouncementsEntryImpl
34      extends AnnouncementsEntryModelImpl implements AnnouncementsEntry {
35  
36      public static final String[] TYPES =
37          PropsUtil.getArray(PropsKeys.ANNOUNCEMENTS_ENTRY_TYPES);
38  
39      public AnnouncementsEntryImpl() {
40      }
41  
42      public long getGroupId() throws PortalException, SystemException {
43          long groupId = 0;
44  
45          long classPK = getClassPK();
46  
47          if (classPK > 0) {
48              String className = getClassName();
49  
50              if (className.equals(Group.class.getName())) {
51                  Group group = GroupLocalServiceUtil.getGroup(classPK);
52  
53                  groupId = group.getGroupId();
54              }
55              else if (className.equals(Organization.class.getName())) {
56                  Organization organization =
57                      OrganizationLocalServiceUtil.getOrganization(classPK);
58  
59                  Group group = organization.getGroup();
60  
61                  groupId = group.getGroupId();
62              }
63          }
64  
65          return groupId;
66      }
67  
68  }