示例#1
0
  public static Layout addLayout(
      Group group,
      boolean privateLayout,
      long parentLayoutId,
      String name,
      String friendlyURL,
      String layoutTemplateId)
      throws Exception {

    ServiceContext serviceContext = new ServiceContext();

    Layout layout =
        LayoutLocalServiceUtil.addLayout(
            group.getCreatorUserId(),
            group.getGroupId(),
            privateLayout,
            parentLayoutId,
            name,
            StringPool.BLANK,
            StringPool.BLANK,
            LayoutConstants.TYPE_PORTLET,
            false,
            friendlyURL,
            serviceContext);

    LayoutTypePortlet layoutTypePortlet = (LayoutTypePortlet) layout.getLayoutType();

    layoutTypePortlet.setLayoutTemplateId(0, layoutTemplateId, false);

    return LayoutLocalServiceUtil.updateLayout(
        layout.getGroupId(),
        layout.isPrivateLayout(),
        layout.getLayoutId(),
        layout.getTypeSettings());
  }
  public static JSONObject toJSONObject(Group model) {
    JSONObject jsonObj = JSONFactoryUtil.createJSONObject();

    jsonObj.put("groupId", model.getGroupId());
    jsonObj.put("companyId", model.getCompanyId());
    jsonObj.put("creatorUserId", model.getCreatorUserId());
    jsonObj.put("classNameId", model.getClassNameId());
    jsonObj.put("classPK", model.getClassPK());
    jsonObj.put("parentGroupId", model.getParentGroupId());
    jsonObj.put("liveGroupId", model.getLiveGroupId());
    jsonObj.put("name", model.getName());
    jsonObj.put("description", model.getDescription());
    jsonObj.put("type", model.getType());
    jsonObj.put("typeSettings", model.getTypeSettings());
    jsonObj.put("friendlyURL", model.getFriendlyURL());
    jsonObj.put("active", model.getActive());

    return jsonObj;
  }
  protected CalendarResource getCalendarResource(long companyId, long groupId)
      throws PortalException, SystemException {

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setCompanyId(companyId);

    long userId = UserLocalServiceUtil.getDefaultUserId(companyId);

    serviceContext.setUserId(userId);

    Group group = groupLocalService.getGroup(groupId);

    if (group.isUser()) {
      return CalendarResourceUtil.getUserCalendarResource(group.getCreatorUserId(), serviceContext);
    }

    return CalendarResourceUtil.getGroupCalendarResource(groupId, serviceContext);
  }