code: private String appendServerPrefix(
          CmsObject cms,
          String link,
          String pathWithOptionalParameters,
          boolean workplaceLink) {
  
          int paramPos = pathWithOptionalParameters.indexOf("?");
          String resourceName = paramPos > -1
          ? pathWithOptionalParameters.substring(0, paramPos)
          : pathWithOptionalParameters;
  
          if (isAbsoluteUri(link) && !hasScheme(link)) {
              // URI is absolute and contains no schema
              // this indicates source and target link are in the same site
              String serverPrefix;
              if (cms.getRequestContext().getCurrentProject().isOnlineProject() && !workplaceLink) {
                  String overrideSiteRoot = (String)(cms.getRequestContext().getAttribute(
                      CmsDefaultLinkSubstitutionHandler.OVERRIDE_SITEROOT_PREFIX + link));
                  // on online project, get the real site name from the site manager
                  CmsSite currentSite = OpenCms.getSiteManager().getSite(
                      overrideSiteRoot != null ? overrideSiteRoot : resourceName,
                      cms.getRequestContext().getSiteRoot());
                  serverPrefix = currentSite.getServerPrefix(cms, resourceName);
              } else {
                  // in offline mode, source must be the workplace
                  // so append the workplace server so links can still be clicked
                  serverPrefix = OpenCms.getSiteManager().getWorkplaceServer();
              }
              link = serverPrefix + link;
          }
          return link;
      }
docs: Returns the link for the given resource in the current project, with full server prefix.<p>
  
  The input link must already have been processed according to the link substitution rules.
  This method does just append the server prefix in case this is requires.<p>
  
  @param cms the current OpenCms user context
  @param link the resource to generate the online link for
  @param pathWithOptionalParameters the resource name
  @param workplaceLink if this is set, use the workplace server prefix even if we are in the Online project
  
  @return the link for the given resource in the current project, with full server prefix