Пример #1
0
  protected ResourceBlock convertResourcePermissions(long companyId, String name, long primKey)
      throws PortalException, SystemException {

    PermissionedModel permissionedModel =
        ResourceBlockLocalServiceUtil.getPermissionedModel(name, primKey);

    long groupId = 0;

    if (permissionedModel instanceof GroupedModel) {
      GroupedModel groupedModel = (GroupedModel) permissionedModel;

      groupId = groupedModel.getGroupId();
    }

    ResourceBlockPermissionsContainer resourceBlockPermissionsContainer =
        getResourceBlockPermissionsContainer(companyId, groupId, name, primKey);

    String permissionsHash =
        ResourceBlockLocalServiceUtil.getPermissionsHash(resourceBlockPermissionsContainer);

    ResourceBlock resourceBlock =
        ResourceBlockLocalServiceUtil.updateResourceBlockId(
            companyId,
            groupId,
            name,
            permissionedModel,
            permissionsHash,
            resourceBlockPermissionsContainer);

    return resourceBlock;
  }
  protected long getGroupId(ClassedModel classedModel) {
    if (!(classedModel instanceof GroupedModel)) {
      return 0;
    }

    GroupedModel groupedModel = (GroupedModel) classedModel;

    return groupedModel.getGroupId();
  }
  protected long getGroupId(AuditedModel auditedModel) {
    long groupId = 0;

    if (auditedModel instanceof GroupedModel) {
      GroupedModel groupedModel = (GroupedModel) auditedModel;

      groupId =
          BeanPropertiesUtil.getLongSilent(
              groupedModel, "resourceGroupId", groupedModel.getGroupId());
    }

    return groupId;
  }
  protected long getCompanyId(ClassedModel classedModel) {
    if (classedModel instanceof AuditedModel) {
      AuditedModel auditedModel = (AuditedModel) classedModel;

      return auditedModel.getCompanyId();
    }

    if (classedModel instanceof GroupedModel) {
      GroupedModel groupedModel = (GroupedModel) classedModel;

      return groupedModel.getCompanyId();
    }

    if (classedModel instanceof StagedModel) {
      StagedModel stagedModel = (StagedModel) classedModel;

      return stagedModel.getCompanyId();
    }

    return 0;
  }