code: public void addRelationToResource(
          CmsRequestContext context,
          CmsResource resource,
          CmsResource target,
          CmsRelationType type,
          boolean importCase)
      throws CmsException {
  
          CmsDbContext dbc = m_dbContextFactory.getDbContext(context);
          try {
              checkOfflineProject(dbc);
              checkPermissions(dbc, resource, CmsPermissionSet.ACCESS_WRITE, true, CmsResourceFilter.ALL);
              m_driverManager.addRelationToResource(dbc, resource, target, type, importCase);
          } catch (Exception e) {
              dbc.report(
                  null,
                  Messages.get().container(
                      Messages.ERR_ADD_RELATION_TO_RESOURCE_3,
                      context.getSitePath(resource),
                      context.getSitePath(target),
                      type),
                  e);
  
          } finally {
              dbc.clear();
          }
      }
docs: Adds a new relation to a given resource.<p>
  
  @param context the request context
  @param resource the resource to add the relation to
  @param target the target of the relation
  @param type the type of the relation
  @param importCase if importing relations
  
  @throws CmsException if something goes wrong
  
  @see #deleteRelationsForResource(CmsRequestContext, CmsResource, CmsRelationFilter)
  @see CmsObject#addRelationToResource(String, String, String)