[END run_asset_discovery]
351042
public static void main(String... args) {
    String org_id = System.getenv("ORGANIZATION_ID");
    if (args.length > 0) {
      org_id = args[0];
    }

    Preconditions.checkNotNull(
        org_id,
        "Organization ID must either be set in the environment variable \"ORGANIZATION_ID\" or passed"
            + " as the first parameter to the program.");

    listAssetsWithFilter(OrganizationName.of(org_id));
  }
1047907
def convert_asset(klass, asset)
      # Convert asset content
      converter = klass.new(asset)

      # Replace asset content and filename
      asset.content = converter.converted
      asset.filename = File.basename(asset.filename, '.*')

      # Add back the output extension if no extension left
      if File.extname(asset.filename) == ''
        asset.filename = "#{asset.filename}#{@type}"
      end
    rescue StandardError => e
      puts "Asset Pipeline: Failed to convert '#{asset.filename}' " \
           "with '#{klass}': #{e.message}"
      raise e
    end
805065
function Buildit$run() {
		var externals, locals, define, out, patterns, walked, that = this;

		define = invert(this.define);
		externals = [];
		locals = {};
		patterns = [];

		each(this.exports, function(filepath, name) {
			var fullpath;

			fullpath = path.join(that.cwd, filepath + '.js');

			patterns.push(fullpath);
		});

		each(this.extensions, function(filepath) {
			var fullpath;

			fullpath = path.join(that.cwd, filepath + '.js');

			patterns.push(fullpath);
		});

		each(this.define, function(filepath, name) {
			var fullpath;

			fullpath = path.join(that.cwd, filepath + '.js');

			patterns.push(fullpath);
		});

		walked = walk(patterns, this.cwd);

		Array.prototype.push.apply(externals, walked.externals);
		unique(externals);

		each(walked.locals, function(file, name) {
			locals[name] = file;
		});

		each(this.define, function(filepath, name) {
			if (!locals.hasOwnProperty(filepath)) {
				throw new Error('Module "' + filepath + '" not found');
			}
		});

		each(this.exports, function(filepath, name) {
			if (!locals.hasOwnProperty(filepath)) {
				throw new Error('Module "' + filepath + '" not found');
			}
		});

		each(this.extensions, function(filepath) {
			if (!locals.hasOwnProperty(filepath)) {
				throw new Error('Module "' + filepath + '" not found');
			}
		});

		out = '';
		out += print.header(this.name, externals);
		out += print.library(externals);
		out += print.mappings(locals, this.cwd);
		out += print.machinery();

		each(locals, function(file, name) {
			out += print.file(name, file.source) + (define[name] ? print.define(define[name], name) : '');
		});

		each(this.extensions, function(filepath) {
			out += print.extension(filepath);
		});

		out += print.exports(this.exports);
		out += print.footer();

		return out;
	}
1019583
function (type, group) {
    if (!config.assets) throw('No assets found in config');
    var t = config.assets[type];
    if (!t) throw('Asset type not found: ' + type);
    var g = t[group];
    if (!g) throw('Asset group not found: ' + group);

    if (!_.isArray(g)) g = [g];
    return _.chain(g).map(function (f) {
        return fss.source(f);
    }).map(function (f) {
        if (fs.lstatSync(f).isDirectory()) return fss.allSourceFilePaths(f);
        return f;
    }).flatten().uniq().filter(function (f) {
        var process = fss.isProcessableFile(f);
        var include = !fss.isHelperFile(_.last(f.split('/')));
        return process && include && !assetFileTypeMismatch(type, f);
    }).value();
}
1298141
def get_assets_by_search(self, asset_query, asset_search):
        """"""
        # Implemented from azosid template for -
        # osid.resource.ResourceSearchSession.get_resources_by_search_template
        if not self._can('search'):
            raise PermissionDenied()
        return self._provider_session.get_assets_by_search(asset_query, asset_search)
303249
@Override
    @Path("/packages")
    @ApiOperation(value="Import discovered asset packages", response=StatusMessage.class)
    @ApiImplicitParams({
        @ApiImplicitParam(name="discoveryUrl", paramType="query", dataType="string"),
        @ApiImplicitParam(name="branch", paramType="query", dataType="string"),
        @ApiImplicitParam(name="discoveryType", paramType="query", required=true),
        @ApiImplicitParam(name="groupId", paramType="query", dataType="string"),
        @ApiImplicitParam(name="packages", paramType="body", required=true, dataType="List")})
    public JSONObject put(String path, JSONObject content, Map<String,String> headers)
            throws ServiceException, JSONException {
        Query query = getQuery(path, headers);
        String discoveryType = query.getFilter("discoveryType");
        if (discoveryType == null)
            throw new ServiceException(ServiceException.BAD_REQUEST, "Missing param: discoveryType");
        List<String> pkgs = new JsonArray(content.getJSONArray("packages")).getList();
        Query discQuery = new Query(path);
        discQuery.setArrayFilter("packages", pkgs.toArray(new String[0]));
        File assetRoot = ApplicationContext.getAssetRoot();
        Bulletin bulletin = null;
        try {
            // central discovery
            if (!discoveryType.isEmpty() && discoveryType.equals("central")) {
                String groupId = query.getFilter("groupId");
                if (groupId == null)
                    throw new ServiceException(ServiceException.BAD_REQUEST, "Missing param: groupId");
                bulletin = SystemMessages.bulletinOn("Asset import in progress...");
                Import importer = new Import(groupId, pkgs);
                importer.setAssetLoc(assetRoot.getPath());
                importer.setForce(true);
                importer.run();
                SystemMessages.bulletinOff(bulletin, "Asset import completed");
                bulletin = null;
                Thread thread = new Thread() {
                    @Override
                    public void run() {
                        this.setName("AssetsCacheRefresh-thread");
                        CacheRegistration.getInstance().refreshCaches(null);
                    }
                };
                thread.start();
            }
            else {
                String discoveryUrl = query.getFilter("discoveryUrl");
                if ("https://github.com/CenturyLinkCloud/mdw.git".equals(discoveryUrl)) {
                    Update update = new Update(null);
                    update.setAssetLoc(assetRoot.getPath());
                    update.setBaseAssetPackages(pkgs);
                    update.setMdwVersion(ApplicationContext.getMdwVersion());
                    update.run();
                }
                else {
                    String branch = query.getFilter("branch");
                    if (branch == null)
                        throw new ServiceException(ServiceException.BAD_REQUEST, "Missing param: groupId");
                    File gitLocalPath = new File(PropertyManager.getProperty(PropertyNames.MDW_GIT_LOCAL_PATH));
                    VersionControlGit vcGit = new VersionControlGit();
                    AssetServices assetServices = ServiceLocator.getAssetServices();
                    GitDiscoverer discoverer = assetServices.getDiscoverer(discoveryUrl);
                    discoverer.setRef(branch);
                    String assetPath = discoverer.getAssetPath();
                    if (discoveryUrl.indexOf('?') != -1)
                        discoveryUrl = discoveryUrl.substring(0, discoveryUrl.indexOf('?'));
                    URL url = new URL(discoveryUrl);
                    String[] userInfo = url.getUserInfo().split(":");
                    File test = new File(gitLocalPath.getAbsolutePath()).getParentFile();
                    if (test != null && gitLocalPath.getPath().length() <= 3)
                        test = new File( gitLocalPath.getAbsolutePath()).getParentFile().getParentFile().getParentFile();
                    File tempfile = new File ( test.getAbsolutePath() + "/" + "mdw_git_discovery_" + java.lang.System.currentTimeMillis());
                    vcGit.connect(discoveryUrl, null, null, tempfile);
                    vcGit.setCredentialsProvider(new UsernamePasswordCredentialsProvider(userInfo[0], userInfo[1]));
                    vcGit.cloneBranch(branch);
                    for (String pkg : pkgs) {
                        String pkgPath = pkg.replace(".", "/");
                        String src = tempfile.getAbsolutePath() + "/" + assetPath + "/" + pkgPath;
                        String dest = ApplicationContext.getAssetRoot().getAbsolutePath() + "/" + pkgPath;
                        Files.createDirectories(Paths.get(dest));
                        Files.move(Paths.get(src), Paths.get(dest), StandardCopyOption.REPLACE_EXISTING);
                    }
                    new Delete(tempfile).run();
                }
            }
        }
        catch (Exception ex) {
            SystemMessages.bulletinOff(bulletin, Level.Error, "Asset import failed: " + ex.getMessage());
            throw new ServiceException(ServiceException.INTERNAL_ERROR, ex.getMessage(), ex);
        }

        return null;
    }
44663
def rails_asset_id(path)
      asset_id = ENV["RAILS_ASSET_ID"]
      return asset_id if asset_id
      File.exists?(path) ? File.mtime(path).to_i.to_s : ''
    end
1361392
def check_assets(self):
        
        if not self.assets_file:
            raise ImproperlyConfigured("You must specify the path to the assets.json file via WEBPACK_ASSETS_FILE")
        elif not os.path.exists(self.assets_file):
            raise ImproperlyConfigured(
                "The file `{file}` was not found, make sure to run the webpack build before the collectstatic command".format(
                    file=self.assets_file))
1098109
protected function registerAssetFinder() : void {
		$this->app->singleton('basset.finder', function($app) {
			return new AssetFinder($app['files'], $app['config'], base_path() . '/resources/assets');
		});
	}
688331
function onAsset(output, asset) {
    var book = output.getBook();
    var options = output.getOptions();
    var bookFS = book.getContentFS();

    var outputFolder = options.get('root');
    var outputPath = path.resolve(outputFolder, asset);

    return fs.ensureFile(outputPath)
    .then(function() {
        return bookFS.readAsStream(asset)
        .then(function(stream) {
            return fs.writeStream(outputPath, stream);
        });
    })
    .thenResolve(output);
}
701500
def find(self, asset_id, query=None, **kwargs):
        

        if query is None:
            query = {}

        normalize_select(query)

        return super(AssetsProxy, self).find(asset_id, query=query, **kwargs)
609207
function assetHashPath(url) {
  const parsedUrl = path.parse(url.getValue());
  const asset = manifest.getAssetValue(parsedUrl.base);
  return compiler.types.String('url("' + asset + '")');
}
1164231
def asset_from_cache(key)
        asset = cache.get(key, true)
        if asset
          asset[:uri]       = expand_from_root(asset[:uri])
          asset[:load_path] = expand_from_root(asset[:load_path])
          asset[:filename]  = expand_from_root(asset[:filename])
          asset[:metadata][:included].map!          { |uri| expand_from_root(uri) } if asset[:metadata][:included]
          asset[:metadata][:links].map!             { |uri| expand_from_root(uri) } if asset[:metadata][:links]
          asset[:metadata][:stubbed].map!           { |uri| expand_from_root(uri) } if asset[:metadata][:stubbed]
          asset[:metadata][:required].map!          { |uri| expand_from_root(uri) } if asset[:metadata][:required]
          asset[:metadata][:to_load].map!           { |uri| expand_from_root(uri) } if asset[:metadata][:to_load]
          asset[:metadata][:to_link].map!           { |uri| expand_from_root(uri) } if asset[:metadata][:to_link]
          asset[:metadata][:dependencies].map!      { |uri| uri.start_with?("file-digest://") ? expand_from_root(uri) : uri } if asset[:metadata][:dependencies]

          asset[:metadata].each_key do |k|
            next unless k =~ /_dependencies\z/
            asset[:metadata][k].map! { |uri| expand_from_root(uri) }
          end
        end
        asset
      end
258104
function generateAssets(generator, output) {
    var assets = output.getAssets();
    var logger = output.getLogger();

    // Is generator ignoring assets?
    if (!generator.onAsset) {
        return Promise(output);
    }

    return Promise.reduce(assets, function(out, assetFile) {
        logger.debug.ln('copy asset "' + assetFile + '"');

        return generator.onAsset(out, assetFile);
    }, output);
}
1269186
def base64_asset_data_uri(asset)
      data = Rack::Utils.escape(EncodingUtils.base64(asset.source))
      "data:#{asset.content_type};base64,#{data}"
    end
424553
def assets(asset_options={})
      logger.debug "asset_options: #{asset_options.inspect}"
      # type of asset to create, used to guess the asset_folder name
      type = asset_options[:type] || :app_asset

      assets = []
      filters = asset_options[:filter] || ['.*']
      match_count = 0
      logger.debug "generating assets array with filter array: #{filters.join(',')}"

      assets_folder = asset_options[:assets_folder] || "assets"
      pattern = File.join(assets_folder, '*/')
      logger.debug "reading from asset type: '#{type}' from assets_folder:'#{assets_folder}' "

      # asset folder can be relative to main config file
      unless Pathname.new(pattern).absolute?
        # base_folder is determined from the configuration file
        # location, if it is not set, then the configuration file wasn't not found
        raise "configuration file not found" unless asset_options[:base_folder]
        base_folder = asset_options[:base_folder]
        pattern = File.expand_path(File.join(base_folder, pattern))
      end
      logger.debug "asset glob pattern: #{pattern}"
      folders = Dir.glob(pattern)
      logger.debug "user assets folder is empty: #{pattern}" if folders.empty?

      folders.sort.each do |folder|
        folder_basename = Pathname.new(folder).basename.to_s
        #logger.debug "matching folder: #{folder} using basename: #{folder_basename}"
        if filters.find {|filter| matches?(folder_basename, filter, asset_options)}
          logger.debug "match found for: #{folder_basename}"
          match_count += 1
          asset = RepoManager::AppAsset.create(type, folder, {})
          assets << asset
          break if ((asset_options[:match] == 'FIRST') || (asset_options[:match] == 'EXACT'))
          raise "match mode = ONE, multiple matching assets found filter" if (asset_options[:match] == 'ONE' && match_count > 1)
        end
      end

      assets
    end
1005227
def call(env)
      # Avoid modifying the session state, don't set cookies, etc
      env["rack.session.options"] ||= {}
      env["rack.session.options"].merge! :defer => true, :skip => true

      root = env["SCRIPT_NAME"]
      path = Rack::Utils.unescape(env["PATH_INFO"].to_s).sub(%r[^/], "")

      if path.include? ".."
        return [403, { "Content-Type" => "text/plain", "Content-Length" => "9" }, ["Forbidden"]]
      end

      # Pull out the md5sum if it's part of the given path
      # e.g. foo/bar-a95c53a7a0f5f492a74499e70578d150.js -> a95c53a7a0f5f492a74499e70578d150
      checksum_tag = bundle_name = nil
      matches = path.match /([^\/]+)-([\da-f]{32})\..+$/
      if matches && matches.size == 3
        bundle_name = matches[1]
        checksum_tag = matches[2]
        path.sub!("-#{checksum_tag}", "")
      end

      # First see if there is a bundle with this name
      asset = Bundle[bundle_name]
      if asset
        # If the checksum doesn't match the bundle, we want to return a 404.
        asset = nil unless asset.checksum == checksum_tag
      else
        # If there is no bundle with this name, find another type of Asset with the name instead.
        asset = Asset[path]
      end

      if asset
        # If the ETag matches, give a 304
        return [304, {}, []] if env["HTTP_IF_NONE_MATCH"] == %Q["#{asset.checksum}"]

        if Pinion.environment == "production"
          # In production, if there is a checksum, cache for a year (because if the asset changes with a
          # redeploy, the checksum will change). If there is no checksum, cache for 10 minutes (this way at
          # worst we only serve 10 minute stale assets, and caches in front of Pinion will be able to help
          # out).
          cache_policy = checksum_tag ? "max-age=31536000" : "max-age=600"
        else
          # Don't cache in dev.
          cache_policy = "must-revalidate"
        end
        headers = {
          "Content-Type" => asset.content_type,
          "Content-Length" => asset.length.to_s,
          "ETag" => %Q["#{asset.checksum}"],
          "Cache-Control" => "public, #{cache_policy}",
          "Last-Modified" => asset.mtime.httpdate,
        }
        body = env["REQUEST_METHOD"] == "HEAD" ? [] : asset
        [200, headers, body]
      else
        [404, { "Content-Type" => "text/plain", "Content-Length" => "9" }, ["Not found"]]
      end
    rescue Exception => e
      # TODO: logging
      STDERR.puts "Error compiling #{path}:"
      STDERR.puts "#{e.class.name}: #{e.message}"
      # TODO: render nice custom errors in the browser
      raise
    end