code: public List<CmsRelation> getRelationsForResource(
          CmsRequestContext context,
          CmsResource resource,
          CmsRelationFilter filter)
      throws CmsException {
  
          List<CmsRelation> result = null;
          CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
          try {
              // check the access permissions
              if (resource != null) {
                  checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_VIEW, false, CmsResourceFilter.ALL);
              }
              result = m_driverManager.getRelationsForResource(dbc, resource, filter);
          } catch (Exception e) {
              dbc.report(
                  null,
                  Messages.get().container(
                      Messages.ERR_READ_RELATIONS_1,
                      (resource != null) ? context.removeSiteRoot(resource.getRootPath()) : "null"),
                  e);
          } finally {
              dbc.clear();
          }
          return result;
      }
docs: Returns all relations for the given resource matching the given filter.<p>
  
  @param context the current user context
  @param resource the resource to retrieve the relations for
  @param filter the filter to match the relation
  
  @return all {@link org.opencms.relations.CmsRelation} objects for the given resource matching the given filter
  
  @throws CmsException if something goes wrong
  
  @see CmsObject#getRelationsForResource(String, CmsRelationFilter)