Пример #1
0
  private Layout _getDefaultUserLayout(long companyId) throws PortalException, SystemException {

    Group group = GroupLocalServiceUtil.getGroup(companyId, GroupImpl.GUEST);

    long plid = LayoutLocalServiceUtil.getDefaultPlid(group.getGroupId(), false);

    return LayoutLocalServiceUtil.getLayout(plid);
  }
Пример #2
0
  protected void deletePermissions_6(long companyId) throws Exception {
    Group group = GroupLocalServiceUtil.getGroup(companyId, GroupConstants.CONTROL_PANEL);

    long plid = LayoutLocalServiceUtil.getDefaultPlid(group.getGroupId(), true);

    Role role = RoleLocalServiceUtil.getRole(companyId, RoleConstants.GUEST);

    List<ResourcePermission> resourcePermissions =
        ResourcePermissionLocalServiceUtil.getRoleResourcePermissions(role.getRoleId());

    for (ResourcePermission resourcePermission : resourcePermissions) {
      if (isControlPanelLayout(plid, resourcePermission.getPrimKey())
          || isPrivateLayout(resourcePermission.getName(), resourcePermission.getPrimKey())) {

        ResourcePermissionLocalServiceUtil.deleteResourcePermission(
            resourcePermission.getResourcePermissionId());
      }
    }
  }
Пример #3
0
  protected long getPlid(long companyId, String pathInfo, String servletPath, long defaultPlid) {

    if (_pattern == _PATTERN_LAYOUT) {
      return defaultPlid;
    }

    if (Validator.isNull(pathInfo) || !pathInfo.startsWith(StringPool.SLASH)) {

      return 0;
    }

    // Group friendly URL

    String friendlyURL = null;

    int pos = pathInfo.indexOf(CharPool.SLASH, 1);

    if (pos != -1) {
      friendlyURL = pathInfo.substring(0, pos);
    } else if (pathInfo.length() > 1) {
      friendlyURL = pathInfo;
    }

    if (Validator.isNull(friendlyURL)) {
      return 0;
    }

    long groupId = 0;
    boolean privateLayout = false;

    try {
      Group group = GroupLocalServiceUtil.getFriendlyURLGroup(companyId, friendlyURL);

      groupId = group.getGroupId();

      if (servletPath.startsWith(PropsValues.LAYOUT_FRIENDLY_URL_PRIVATE_GROUP_SERVLET_MAPPING)
          || servletPath.startsWith(PropsValues.LAYOUT_FRIENDLY_URL_PRIVATE_USER_SERVLET_MAPPING)) {

        privateLayout = true;
      } else if (servletPath.startsWith(PropsValues.LAYOUT_FRIENDLY_URL_PUBLIC_SERVLET_MAPPING)) {

        privateLayout = false;
      }
    } catch (NoSuchLayoutException nsle) {
      if (_log.isWarnEnabled()) {
        _log.warn(nsle);
      }
    } catch (Exception e) {
      if (_log.isWarnEnabled()) {
        _log.warn(e);
      }

      return 0;
    }

    // Layout friendly URL

    friendlyURL = null;

    if ((pos != -1) && ((pos + 1) != pathInfo.length())) {
      friendlyURL = pathInfo.substring(pos);
    }

    if (Validator.isNull(friendlyURL)) {
      try {
        long plid = LayoutLocalServiceUtil.getDefaultPlid(groupId, privateLayout);

        return plid;
      } catch (Exception e) {
        _log.warn(e);

        return 0;
      }
    } else if (friendlyURL.endsWith(StringPool.FORWARD_SLASH)) {
      friendlyURL = friendlyURL.substring(0, friendlyURL.length() - 1);
    }

    // If there is no layout path take the first from the group or user

    try {
      Layout layout =
          LayoutLocalServiceUtil.getFriendlyURLLayout(groupId, privateLayout, friendlyURL);

      return layout.getPlid();
    } catch (NoSuchLayoutException nsle) {
      _log.warn(nsle);

      return 0;
    } catch (Exception e) {
      _log.error(e);

      return 0;
    }
  }