Returns the design-time package for a specified assetId
(Returns the first match so does not support the same asset in multiple packages).
554380
public static Package getAssetPackage(Long assetId) throws CachingException {
        for (Package pkg : getPackageList()) {
            if (pkg.containsAsset(assetId))
                return pkg;
        }
        return null;
    }
648171
public function getPackageAssetsWebPath($package_name)
    {
        $package = $this->getPackage($package_name);
        return $this->buildWebPath($package->getAssetsPath());
    }
886475
public static Asset getAsset(AssetKey key) {
        int delimIdx = getDelimIndex(key);
        if (delimIdx > 0) {
            // look in package rule sets
            String pkgName = key.getName().substring(0, delimIdx);
            String assetName = key.getName().substring(delimIdx + 1);
            try {
                Package pkgVO = PackageCache.getPackage(pkgName);
                if (pkgVO != null) {
                    for (Asset asset : pkgVO.getAssets()) {
                        if (asset.getName().equals(assetName))
                            return getAsset(new AssetKey(asset.getId()));
                        if (Asset.JAVA.equals(key.getLanguage()) && asset.getName().equals(assetName + ".java"))
                            return getAsset(new AssetKey(asset.getId()));
                        if (Asset.GROOVY.equals(key.getLanguage()) && asset.getName().equals(assetName + ".groovy"))
                            return getAsset(new AssetKey(asset.getId()));
                    }
                }
            }
            catch (CachingException ex) {
                logger.severeException(ex.getMessage(), ex);
            }
            // try to load (for archived compatibility case)
            Asset asset = loadAsset(key);
            if (asset != null) {
                getAssetMap();
                synchronized(assetMap) {
                    assetMap.put(new AssetKey(asset), asset);
                }
                return asset;
            }
            return null;  // not found
        }

        getAssetMap();
        synchronized(assetMap) {
            for (AssetKey mapKey : assetMap.keySet()) {
                if (key.equals(mapKey))
                    return assetMap.get(mapKey);
            }
        }

        Asset asset = null;
        asset = loadAsset(key);
        if (asset != null) {
            synchronized(assetMap) {
                assetMap.put(new AssetKey(asset), asset);
            }
        }
        return asset;
    }
397740
function getScopeBasedDesignTime(mMetadata, sScopeKey) {
		var mResult = mMetadata;

		if ("default" in mMetadata) {
			mResult = merge(
				{},
				mMetadata.default,
				sScopeKey !== "default" && mMetadata[sScopeKey] || null
			);
		}

		return mResult;
	}
187378
public function getAssetUrl(\Twig_Environment $twig, $path, $packageName = null)
    {
        /** @var AssetExtension $asset */
        $asset = $twig->getExtension('Symfony\Bridge\Twig\Extension\AssetExtension');

        if (isset($this->assetMap[$path])) {
            $path = $this->assetMap[$path];
        }

        return $asset->getAssetUrl($path, $packageName);
    }
195765
function getAssetInfo (queryOptions, { assetId }) {
  return sendQuery(
    queryOptions,
    queryHelper.addQuery(
      queryHelper.emptyQuery(),
      'getAssetInfo',
      {
        assetId
      }
    ),
    (resolve, reject, responseName, response) => {
      if (responseName !== 'ASSET_RESPONSE') {
        const error = JSON.stringify(response.toObject().errorResponse)
        return reject(new Error(`Query response error: expected=ASSET_RESPONSE, actual=${responseName}\nReason: ${error}`))
      }

      const info = response.getAssetResponse().toObject().asset
      resolve(info)
    }
  )
}
1250496
@SuppressWarnings("rawtypes")
    static String validateProductMatches(String feature, String dependency, List productMatchers, File installDir, boolean installingAsset) {
        wlp.lib.extract.ReturnCode validInstallRC = SelfExtractor.validateProductMatches(installDir, productMatchers);
        String errMsg = "";
        if (validInstallRC != wlp.lib.extract.ReturnCode.OK) {
            String productName = InstallConstants.PRODUCTNAME;
            Object[] params = validInstallRC.getParameters();
            if (validInstallRC.getMessageKey().equals("invalidVersion") || validInstallRC.getMessageKey().equals("invalidEdition")) {
                int productVersion = 0;
                int matchVersion = 1;
                int productEdition = 2;
                int matchEdition = 3;

                if (validInstallRC.getMessageKey().equals("invalidEdition")) {
                    productVersion = 2;
                    matchVersion = 3;
                    productEdition = 0;
                    matchEdition = 1;
                }
                String version = (String) params[productVersion];
                String appliesToVersion = (String) params[matchVersion];
                if (appliesToVersion == null || version.equals(appliesToVersion))
                    appliesToVersion = "";

                @SuppressWarnings("unchecked")
                List<String> editions = (List<String>) params[matchEdition];
                String edition = InstallUtils.getEditionName(installDir, (String) params[productEdition]);
                StringBuilder applicableProducts = new StringBuilder();
                applicableProducts.append(InstallUtils.NEWLINE);

                //no editions requirement
                if (editions == null || editions.size() == 0) {
                    editions = InstallUtils.ALL_EDITIONS;
                }

                if (((String) params[productEdition]).equalsIgnoreCase("Liberty Early Access")) {
                    editions = new ArrayList<String>();
                    editions.add("Early Access");
                }

                Collections.sort(editions);
                Map<String, String> productMap = new HashMap<String, String>();
                applicableProducts.append(InstallUtils.NEWLINE);
                for (String e : editions) {
                    String editionName = "";
                    editionName = InstallUtils.getEditionName(e);
                    if (!productMap.containsKey(editionName)) {
                        String product = "- " + productName + (editionName.isEmpty() ? "" : " ") + editionName + " " + appliesToVersion;
                        productMap.put(editionName, product);
                        applicableProducts.append(product);
                        applicableProducts.append(InstallUtils.NEWLINE);
                    }
                }
                applicableProducts.append(InstallUtils.NEWLINE);
                //installing asset has invalid product version and/or edition
                if (dependency == null || dependency.isEmpty()) {
                    if (appliesToVersion.equals("")) { //installing asset has invalid product edition only

                        if (((String) params[productEdition]).equalsIgnoreCase("Open_Web") && productName.equalsIgnoreCase("IBM WebSphere Application Server Liberty")) {
                            errMsg = Messages.INSTALL_KERNEL_MESSAGES.getLogMessage(installingAsset ? "ERROR_ASSET_INVALID_PRODUCT_EDITION" : "ERROR_INVALID_PRODUCT_EDITION_FOR_OPEN_LIBERTY_FEATURE",
                                                                                    new Object[] { feature });
                        } else {

                            errMsg = Messages.INSTALL_KERNEL_MESSAGES.getLogMessage(installingAsset ? "ERROR_ASSET_INVALID_PRODUCT_EDITION" : "ERROR_INVALID_PRODUCT_EDITION",
                                                                                    new Object[] { feature, productName, edition, applicableProducts.toString(), productName,
                                                                                                   edition });
                        }

                    } else {
                        errMsg = Messages.INSTALL_KERNEL_MESSAGES.getLogMessage(installingAsset ? "ERROR_ASSET_INVALID_PRODUCT_EDITION_VERSION" : "ERROR_INVALID_PRODUCT_EDITION_VERSION",
                                                                                new Object[] { feature, productName, edition, version, applicableProducts.toString() });
                    }
                } else
                    errMsg = Messages.INSTALL_KERNEL_MESSAGES.getLogMessage(installingAsset ? "ERROR_ASSET_DEPENDENT_INVALID_VERSION_EDITION" : "ERROR_DEPENDENT_INVALID_VERSION_EDITION",
                                                                            new Object[] { feature, dependency, productName, edition, version,
                                                                                           applicableProducts.toString() });

            } else if (validInstallRC.getMessageKey().equals("invalidInstallType")) {
                errMsg = Messages.INSTALL_KERNEL_MESSAGES.getLogMessage(installingAsset ? "ERROR_ASSET_INVALID_PRODUCT_INSTALLTYPE" : "ERROR_INVALID_PRODUCT_INSTALLTYPE",
                                                                        new Object[] { feature, params[0], params[1] });
            }

            if (errMsg.isEmpty()) {
                errMsg = Messages.INSTALL_KERNEL_MESSAGES.getLogMessage(installingAsset ? "ERROR_ASSET_NOT_APPLICABLE" : "ERROR_FEATURE_NOT_APPLICABLE", feature,
                                                                        installDir.getAbsolutePath(),
                                                                        validInstallRC.getErrorMessage());
            }
        }
        return errMsg;
    }
360873
def get_asset_id(self):
        
        # Implemented from template for osid.learning.Activity.get_objective_id
        if not bool(self._my_map['assetId']):
            raise errors.IllegalState('asset empty')
        return Id(self._my_map['assetId'])
458228
public PackageAssets getAssets(String packageName, boolean withVcsInfo) throws ServiceException {
        try {
            PackageDir pkgDir = getPackageDir(packageName);
            if (pkgDir == null) {
                pkgDir = getGhostPackage(packageName);
                if (pkgDir == null)
                    throw new DataAccessException("Missing package metadata directory: " + packageName);
            }
            List<AssetInfo> assets = new ArrayList<>();
            if (!DiffType.MISSING.equals(pkgDir.getVcsDiffType())) {
                for (File file : pkgDir.listFiles()) {
                    if (file.isFile()) {
                        AssetFile assetFile = pkgDir.getAssetFile(file);
                        if (!MdwIgnore.isIgnore(assetFile))
                            assets.add(new AssetInfo(assetFile));
                    }
                }
            }

            PackageAssets pkgAssets = new PackageAssets(pkgDir);
            pkgAssets.setAssets(assets);

            if (withVcsInfo) {
                CodeTimer timer = new CodeTimer("AssetServices", true);
                addVersionControlInfo(pkgAssets);
                pkgAssets.sort();
                timer.stopAndLogTiming("addVersionControlInfo(PackageAssets)");
            }

            return pkgAssets;
        }
        catch (Exception ex) {
            throw new ServiceException(ex.getMessage(), ex);
        }
    }
318916
def get_asset_content_lookup_session_for_repository(self, repository_id):
        """"""
        return getattr(sessions, 'AssetContentLookupSession')(
            provider_session=self._provider_manager.get_asset_content_lookup_session_for_repository(repository_id),
            authz_session=self._authz_session)
126333
@GET
  @Path("/{asset: .+}")
  public Response getSwaggerUiAsset(@PathParam("asset") String assetPath) {
    if (!ASSETS.contains(assetPath)) {
      return Response.status(404).build();
    }

    InputStream stream = getClass().getResourceAsStream("ui-dist/" + assetPath);
    return Response.ok(stream).build();
  }
476440
public File getCompiled(AssetInfo asset, File starter) throws IOException, ServiceException {
        File file;
        synchronized(WebpackCache.class) {
            file = webpackAssets.get(asset);
            if (file == null || !file.exists() || file.lastModified() < asset.getFile().lastModified()
                    || (starter != null && file.lastModified() < starter.lastModified())) {
                file = getOutput(asset);
                compile(asset, starter, file);
                return file;
            }
        }
        return file;
    }
636629
public DesignDocument get(String id) {
        assertNotEmpty(id, "id");
        return db.find(DesignDocument.class, ensureDesignPrefix(id));
    }
1193028
function getClosestPackage(modulePath) {
  let root;
  let pkg;

  // Catch findRoot or require errors
  try {
    root = findRoot(modulePath);
    pkg = require(path.join(root, "package.json"));
  } catch (e) {
    return null;
  }

  // If the package.json does not have a name property, try again from
  // one level higher.
  // https://github.com/jsdnxx/find-root/issues/2
  // https://github.com/date-fns/date-fns/issues/264#issuecomment-265128399
  if (!pkg.name) {
    return getClosestPackage(path.resolve(root, ".."));
  }

  return {
    package: pkg,
    path: root
  };
}
302748
function findPackage(config, match) {
  var map = getPackageMap(config.relativeTo, config.packages);

  return _.reduce(map, function (prev, pkg) {

    // Resolve using last priority. Priority:
    // 1. package is a file
    // 2. package granularity (done by file depth)
    if (pkg.regexp.test(match) && (!prev || (pkg.dir && prev.dir && pkg.depth >= pkg.depth) || pkg.file)) {
      return pkg;
    } else {
      return prev;
    }

  }, null);
}
1065814
@Override
    public Asset<?> assetAt(String path) {
        List<WebJarLib> candidates = findLibsContaining(path);

        if (candidates.size() == 1) {
            // Perfect ! only one match
            return new DefaultAsset<>(
                    "/libs/" + candidates.get(0).name + "/" + candidates.get(0).version + "/" + path,
                    candidates.get(0).get(path),
                    candidates.get(0).toString(),
                    candidates.get(0).lastModified(),
                    CacheUtils.computeEtag(candidates.get(0).lastModified(), configuration, crypto)
            );
        } else if (candidates.size() > 1) {
            // Several candidates
            logger().warn("{} WebJars provide '{}' - returning the one from {}-{}", candidates.size(), path,
                    candidates.get(0).name, candidates.get(0).version);
            return new DefaultAsset<>(
                    "/libs/" + candidates.get(0).name + "/" + candidates.get(0).version + "/" + path,
                    candidates.get(0).get(path),
                    candidates.get(0).toString(),
                    candidates.get(0).lastModified(),
                    CacheUtils.computeEtag(candidates.get(0).lastModified(), configuration, crypto)
            );
        } else {
            Matcher matcher = PATTERN.matcher(path);
            if (!matcher.matches()) {
                // It should have been handled by the path match.
                return null;
            }

            final String name = matcher.group(1);
            final String version = matcher.group(3);
            if (version != null) {
                String rel = matcher.group(4);
                // We have a name and a version
                // Try to find the matching library
                WebJarLib lib = find(name, version);
                if (lib != null) {
                    return new DefaultAsset<>(
                            rel,
                            lib.get(rel),
                            lib.toString(),
                            lib.lastModified(),
                            CacheUtils.computeEtag(lib.lastModified(), configuration, crypto)
                    );
                }
                // If not found, it may be because the version is not really the version but a segment of the path.
            }
            // If we reach this point it means that the name/version lookup has failed, try without the version
            String rel = matcher.group(4);
            if (version != null) {
                // We have a group 3
                rel = version + "/" + rel;
            }

            List<WebJarLib> libs = find(name);
            if (libs.size() == 1) {
                // Only on library has the given name
                if (libs.get(0).contains(rel)) {
                    WebJarLib lib = libs.get(0);
                    return new DefaultAsset<>(
                            "/libs/" + lib.name + "/" + lib.version + "/" + rel,
                            lib.get(rel),
                            lib.toString(),
                            lib.lastModified(),
                            CacheUtils.computeEtag(lib.lastModified(), configuration, crypto)
                    );
                }
            } else if (libs.size() > 1) {
                // Several candidates
                WebJarLib higher = null;
                ComparableVersion higherVersion = null;
                for (WebJarLib lib: libs) {
                    if (lib.contains(rel)) {
                        if(higher == null) {
                            higher = lib;
                            higherVersion = new ComparableVersion(higher.version);
                        } else {
                            ComparableVersion newVersion = new ComparableVersion(lib.version);
                            if(newVersion.compareTo(higherVersion) > 0) {
                                higher = lib;
                                higherVersion = new ComparableVersion(higher.version);
                            }
                        }
                    }
                }
                if(higher != null) {
                    logger().warn("{} WebJars match the request '{}' - returning the resource from {}-{}",
                            libs.size(), path, higher.name, higher.version);
                    return new DefaultAsset<>(
                            "/libs/" + higher.name + "/" + higher.version + "/" + rel,
                            higher.get(rel),
                            higher.toString(),
                            higher.lastModified(),
                            CacheUtils.computeEtag(higher.lastModified(), configuration, crypto)
                    );
                }

            }

            return null;
        }
    }
66211
def get(self, id: int) -> AssetClass:
        
        self.open_session()
        item = self.session.query(AssetClass).filter(
            AssetClass.id == id).first()
        return item