Search in sources :

Example 1 with RepositoryDigest

use of aQute.bnd.service.repository.RepositoryDigest in project bnd by bndtools.

the class Workspace method _repodigests.

/**
	 * Return the repository signature digests. These digests are a unique id
	 * for the contents of the repository
	 */
public Object _repodigests(String[] args) throws Exception {
    Macro.verifyCommand(args, "${repodigests;[;<repo names>]...}, get the repository digests", null, 1, 10000);
    List<RepositoryPlugin> repos = getRepositories();
    if (args.length > 1) {
        repos: for (Iterator<RepositoryPlugin> it = repos.iterator(); it.hasNext(); ) {
            String name = it.next().getName();
            for (int i = 1; i < args.length; i++) {
                if (name.equals(args[i])) {
                    continue repos;
                }
            }
            it.remove();
        }
    }
    List<String> digests = new ArrayList<String>();
    for (RepositoryPlugin repo : repos) {
        try {
            if (repo instanceof RepositoryDigest) {
                byte[] digest = ((RepositoryDigest) repo).getDigest();
                digests.add(Hex.toHexString(digest));
            } else {
                if (args.length != 1)
                    error("Specified repo %s for ${repodigests} was named but it is not found", repo.getName());
            }
        } catch (Exception e) {
            if (args.length != 1)
                error("Specified repo %s for digests is not found", repo.getName());
        // else Ignore
        }
    }
    return join(digests, ",");
}
Also used : RepositoryDigest(aQute.bnd.service.repository.RepositoryDigest) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) IOException(java.io.IOException) TimeLimitExceededException(javax.naming.TimeLimitExceededException)

Aggregations

RepositoryPlugin (aQute.bnd.service.RepositoryPlugin)1 RepositoryDigest (aQute.bnd.service.repository.RepositoryDigest)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 TimeLimitExceededException (javax.naming.TimeLimitExceededException)1