code: public CmsPublishList getRelatedResourcesToPublish(
          CmsRequestContext context,
          CmsPublishList publishList,
          CmsRelationFilter filter)
      throws CmsException {
  
          if (!publishList.isDirectPublish()) {
              throw new CmsIllegalArgumentException(
                  Messages.get().container(Messages.ERR_GET_RELATED_RESOURCES_PUBLISH_PROJECT_0));
          }
  
          CmsPublishList ret = null;
          CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
          try {
              ret = m_driverManager.getRelatedResourcesToPublish(dbc, publishList, filter);
              checkPublishPermissions(dbc, ret);
          } catch (Exception e) {
              dbc.report(
                  null,
                  Messages.get().container(
                      Messages.ERR_GET_RELATED_RESOURCES_PUBLISH_DIRECT_1,
                      CmsFileUtil.formatResourceNames(context, publishList.getDirectPublishResources())),
                  e);
          } finally {
              dbc.clear();
          }
          return ret;
      }
docs: Returns a new publish list that contains the unpublished resources related
  to all resources in the given publish list, the related resources exclude
  all resources in the given publish list and also locked (by other users) resources.<p>
  
  @param context the current cms context
  @param publishList the publish list to exclude from result
  @param filter the relation filter to use to get the related resources
  
  @return a new publish list that contains the related resources
  
  @throws CmsException if something goes wrong
  
  @see org.opencms.publish.CmsPublishManager#getRelatedResourcesToPublish(CmsObject, CmsPublishList)