Analyzes an artifact's tracing links by returning a web page.
@param \FeaturePhp\Artifact\Artifact $artifact
@param bool $textOnly whether to render text or HTML
@return string
420025
public function renderTracingLinkAnalysis($artifact, $textOnly = false) {
        return (new fphp\Artifact\TracingLinkRenderer($this->trace($artifact)))->render($textOnly);
    }
918573
private function &getCSPObject($reportOnly)
    {
        if ( ! isset($reportOnly) or ! $reportOnly)
        {
            $csp = &$this->csp;
        }
        else
        {
            $csp = &$this->cspro;
        }

        return $csp;
    }
126861
public static function get_areas($tagcollid = null, $enabledonly = false) {
        global $DB;
        $cache = cache::make('core', 'tags');
        if (($itemtypes = $cache->get('tag_area')) === false) {
            $colls = core_tag_collection::get_collections();
            $defaultcoll = reset($colls);
            $itemtypes = array();
            $areas = $DB->get_records('tag_area', array(), 'component,itemtype');
            foreach ($areas as $area) {
                if ($colls[$area->tagcollid]->component) {
                    $area->locked = true;
                }
                $itemtypes[$area->itemtype][$area->component] = $area;
            }
            $cache->set('tag_area', $itemtypes);
        }
        if ($tagcollid || $enabledonly) {
            $rv = array();
            foreach ($itemtypes as $itemtype => $it) {
                foreach ($it as $component => $v) {
                    if (($v->tagcollid == $tagcollid || !$tagcollid) && (!$enabledonly || $v->enabled)) {
                        $rv[$itemtype][$component] = $v;
                    }
                }
            }
            return $rv;
        }
        return $itemtypes;
    }
695235
public function findAllTreeItems($publishedOnly = false)
    {
        $filter = $publishedOnly ? ['published' => true] : [];
        return $this->repository->findBy($filter, ['lft' => 'ASC']);
    }
239094
public List<Artifact> getArtifacts(final Boolean hasLicense) throws GrapesCommunicationException {
        final Client client = getClient();
        final WebResource resource = client.resource(serverURL).path(RequestUtils.getArtifactsPath());
        final ClientResponse response = resource.queryParam(ServerAPI.HAS_LICENSE_PARAM, hasLicense.toString())
                .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);

        client.destroy();
        if(ClientResponse.Status.OK.getStatusCode() != response.getStatus()){
            final String message = "Failed to get artifacts";
            if(LOG.isErrorEnabled()) {
                LOG.error(String.format(HTTP_STATUS_TEMPLATE_MSG, message, response.getStatus()));
            }
            throw new GrapesCommunicationException(message, response.getStatus());
        }

        return response.getEntity(ArtifactList.class);
    }
860288
public static String getVersion(String groupId, String artifactId) {
        String key = "" + groupId + "/" + artifactId;
        Map<String, String> map = getGroupArtifactVersionMap();
        String version = map.get(key);
        if (version == null) {
            getLOG().warn("Could not find the version for groupId: " + groupId + " artifactId: " + artifactId + " in: " + map);
        }
        return version;
    }
556716
private static Artifact validateArtifact(final Artifact artifact) {
        if (!artifact.getFile().isFile()) {
            throw new IllegalArgumentException("<"+artifact.getFile()+"> is not a file");
        }
        return artifact;
    }
398623
@Override
    public File findArtifact(final Artifact artifact) {
        String type = artifact.getProperty("type", "jar");
        if ("ceylon-jar".equals(type) || "car".equals(type)) {
            if ("ceylon-jar".equals(type)) {
                type = "jar";
            }

            File art = new File(CeylonUtil.ceylonSystemFullPath(artifact, type));
            
            if (art.isFile()) {
            	 if (logger != null) {
            		 logger.info("Resolved from Ceylon repo: " + artifact);
            	 }
                artifact.setFile(art);
                return art;
            }
        } 
        return null;
    }
1052431
public static function get_areas_names($tagcollid, $enabledonly = true) {
        $allitemtypes = core_tag_area::get_areas($tagcollid, $enabledonly);
        $itemtypes = array();
        foreach ($allitemtypes as $itemtype => $it) {
            foreach ($it as $component => $v) {
                $itemtypes[$v->id] = core_tag_area::display_name($component, $itemtype);
            }
        }
        return $itemtypes;
    }
491034
public static String derivePomUrl(String artifactId, String version, String artifactUrl) {
        return artifactUrl.substring(0, artifactUrl.lastIndexOf('/')) + '/' + artifactId + '-' + version + ".pom";
    }
936426
private function analyzeModel($model, $textOnly) {
        $featureNum = count($model->getFeatures());
        $rootFeatureName = $model->getRootFeature()->getName();
        $constraintNum = count($model->getConstraintSolver()->getConstraints());
        $ruleNum = count($model->getXmlModel()->getRules());

        $str = "";
        $maxLen = fphp\Helper\_String::getMaxLength($model->getFeatures(), "getName");
        
        if ($textOnly)
            $str .= "The given feature model with the root feature " .
                 "$this->accentColor$rootFeatureName$this->defaultColor has the following $featureNum features:\n\n";
        else {
            $str .= "<div>";
            $str .= "<p>The given feature model with the root feature <span class='feature'>$rootFeatureName</span> "
                 . "has the following $featureNum features:</p>";
            $str .= "<ul>";
        }

        foreach ($model->getFeatures() as $feature) {
            $description = $feature->getDescription();
            if ($this->productLine)
                $class = $this->productLine->getArtifact($feature)->isGenerated() ? "" : "unimplemented";
            else
                $class = "";

            if ($textOnly) {
                $color = $class === "unimplemented" ? "" : $this->accentColor;
                $str .= sprintf("%s%-{$maxLen}s$this->defaultColor %s\n", $color, $feature->getName(),
                                fphp\Helper\_String::truncate($description));
            } else
                $str .= "<li><span class='feature $class'>"
                     . $feature->getName()
                     . ($description ? "</span><br /><span style='font-size: 0.8em'>"
                        . str_replace("\n", "<br />", $description) . "</span>" : "")
                     . "</li>";
        }

        if ($textOnly)
            $str .= "\nThere are $constraintNum feature constraints ($ruleNum of them cross-tree constraints).\n";
        else {
            $str .= "</ul>";
            $str .= "<p>There are $constraintNum feature constraints ($ruleNum of them cross-tree constraints).</p>";
            $str .= "</div>";
        }
        return $str;
    }
1196973
private void downloadExtension(Artifact versionedArtifact, File toLocation)
  {
    final CollectRequest collectRequest = new CollectRequest();
    collectRequest.setRoot(new Dependency(versionedArtifact, JavaScopes.RUNTIME));
    final DependencyRequest dependencyRequest = new DependencyRequest(
        collectRequest,
        DependencyFilterUtils.andFilter(
            DependencyFilterUtils.classpathFilter(JavaScopes.RUNTIME),
            new DependencyFilter()
            {
              @Override
              public boolean accept(DependencyNode node, List<DependencyNode> parents)
              {
                String scope = node.getDependency().getScope();
                if (scope != null) {
                  scope = StringUtils.toLowerCase(scope);
                  if ("provided".equals(scope)) {
                    return false;
                  }
                  if ("test".equals(scope)) {
                    return false;
                  }
                  if ("system".equals(scope)) {
                    return false;
                  }
                }
                if (accept(node.getArtifact())) {
                  return false;
                }

                for (DependencyNode parent : parents) {
                  if (accept(parent.getArtifact())) {
                    return false;
                  }
                }

                return true;
              }

              private boolean accept(final Artifact artifact)
              {
                return exclusions.contains(artifact.getGroupId());
              }
            }
        )
    );

    try {
      log.info("Start downloading extension [%s]", versionedArtifact);
      final List<Artifact> artifacts = aether.resolveArtifacts(dependencyRequest);

      for (Artifact artifact : artifacts) {
        if (!exclusions.contains(artifact.getGroupId())) {
          log.info("Adding file [%s] at [%s]", artifact.getFile().getName(), toLocation.getAbsolutePath());
          FileUtils.copyFileToDirectory(artifact.getFile(), toLocation);
        } else {
          log.debug("Skipped Artifact[%s]", artifact);
        }
      }
    }
    catch (Exception e) {
      log.error(e, "Unable to resolve artifacts for [%s].", dependencyRequest);
      throw new RuntimeException(e);
    }
    log.info("Finish downloading extension [%s]", versionedArtifact);
  }
681395
public function get_readers($nameonly = false) {
        if (!isset($this->logmanager)) {
            $this->logmanager = get_log_manager();
        }

        $readers = $this->logmanager->get_readers('core\log\sql_reader');
        if ($nameonly) {
            foreach ($readers as $pluginname => $reader) {
                $readers[$pluginname] = $reader->get_name();
            }
        }
        return $readers;
    }
1090285
protected function _getSourcePath($trace, $fileOnly = false)
    {
        $path         = '';
        $currentTrace = $this->_getLastTrace($trace);

        if (isset($currentTrace['file'])) {
            $path = $this->_getRalativePath($currentTrace['file']);

            if ($fileOnly && $path) {
                $path = pathinfo($path, PATHINFO_BASENAME);
            }

            if (isset($currentTrace['line']) && $path) {
                $path = $path . ':' . $currentTrace['line'];
            }
        }

        if (!$path) {
            $path = 'undefined:0';
        }

        return $path;
    }
1338146
protected String getArtifactId(String artifactId) {
        return this.artifactId == null || this.artifactId.length() == 0
                ? artifactId
                : this.artifactId;
    }
778620
@Override
  public ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts)
      throws UnableToCompleteException {
    ArtifactSet toReturn = super.link(logger, context, artifacts);

    // Create the general cache-manifest resource for the landing page:
    toReturn.add(emitLandingPageCacheManifest(context, logger, toReturn, staticCachedFiles()));

    return toReturn;
  }
1250535
private Artifact<?> emitLandingPageCacheManifest(LinkerContext context, TreeLogger logger,
      ArtifactSet artifacts, String[] staticFiles) throws UnableToCompleteException {
    // Create a string of cacheable resources
    StringBuilder publicSourcesSb = new StringBuilder();
    StringBuilder publicStaticSourcesSb = new StringBuilder();

    // Iterate over all emitted artifacts, and collect all cacheable artifacts
    for (@SuppressWarnings("rawtypes")
    Artifact artifact : artifacts) {
      if (artifact instanceof EmittedArtifact) {
        EmittedArtifact ea = (EmittedArtifact) artifact;
        String path = "/" + context.getModuleFunctionName() + "/" + ea.getPartialPath();

        if (accept(path)) {
          publicSourcesSb.append(path + "\n");
        }
      }
    }

    // Iterate over all static files
    if (staticFiles != null) {
      for (String staticFile : staticFiles) {
        if (accept(staticFile)) {
          publicStaticSourcesSb.append(staticFile + "\n");
        }
      }
    }

    // build cache list
    StringBuilder sb = new StringBuilder();
    sb.append("CACHE MANIFEST\n");
    sb.append("# Unique id #" + (new Date()).getTime() + "." + Math.random() + "\n");
    // we have to generate this unique id because the resources can change but
    // the hashed cache.html files can remain the same.
    sb.append("# Note: must change this every time for cache to invalidate\n");
    sb.append("\n");
    sb.append("CACHE:\n");
    sb.append(publicSourcesSb.toString());
    sb.append("# Static cached files\n");
    sb.append(publicStaticSourcesSb.toString());
    sb.append("\n\n");
    sb.append("# All other resources require the user to be online.\n");
    sb.append("NETWORK:\n");
    sb.append("*\n");

    logger.log(TreeLogger.DEBUG, "Make sure you have the following"
        + " attribute added to your landing page's <html> tag: <html manifest=\""
        + context.getModuleFunctionName() + "/" + MANIFEST + "\">");

    // Create the manifest as a new artifact and return it:
    return emitString(logger, sb.toString(), MANIFEST);
  }