com.vmware.gerrit.owners.OwnersStoredValues Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gerrit-owners Show documentation
Show all versions of gerrit-owners Show documentation
Gerrit Plugin that provides a Prolog predicate for enabling per directory code review requirements.
The newest version!
/*
* Copyright (c) 2013 VMware, Inc. All Rights Reserved.
*/
package com.vmware.gerrit.owners;
import com.vmware.gerrit.owners.common.PathOwners;
import com.google.gerrit.rules.PrologEnvironment;
import com.google.gerrit.rules.StoredValue;
import com.google.gerrit.rules.StoredValues;
import com.google.gerrit.server.account.AccountResolver;
import com.google.gerrit.server.patch.PatchList;
import com.google.gwtorm.server.OrmException;
import com.googlecode.prolog_cafe.lang.Prolog;
import com.googlecode.prolog_cafe.lang.SystemException;
import org.eclipse.jgit.lib.Repository;
/**
* StoredValues for the Gerrit OWNERS plugin.
*/
public class OwnersStoredValues {
public static StoredValue PATH_OWNERS = new StoredValue() {
@Override
protected PathOwners createValue(Prolog engine) {
PatchList patchList = StoredValues.PATCH_LIST.get(engine);
Repository repository = StoredValues.REPOSITORY.get(engine);
PrologEnvironment env = (PrologEnvironment) engine.control;
AccountResolver resolver = env.getInjector().getInstance(AccountResolver.class);
try {
return new PathOwners(resolver, repository, patchList);
} catch (OrmException e) {
throw new SystemException(e.getMessage());
}
}
};
private OwnersStoredValues() {
}
}