Rename getCurrentUser to getUser
It is never ambiguous to say "User" instead of "CurrentUser". Save some typing. Change-Id: I03a051f1fd3758ba63749cded20a7c135b6cf58a
This commit is contained in:
@@ -76,7 +76,7 @@ public class AcceptanceTestRequestScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new IllegalStateException("user == null, forgot to set it?");
|
throw new IllegalStateException("user == null, forgot to set it?");
|
||||||
}
|
}
|
||||||
@@ -153,7 +153,7 @@ public class AcceptanceTestRequestScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Context newContinuingContext(Context ctx) {
|
private Context newContinuingContext(Context ctx) {
|
||||||
return new Context(ctx, ctx.getSession(), ctx.getCurrentUser());
|
return new Context(ctx, ctx.getSession(), ctx.getUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Context set(Context ctx) {
|
public Context set(Context ctx) {
|
||||||
|
@@ -187,7 +187,7 @@ class InProcessProtocol extends TestProtocol<Context> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
return get(USER_KEY, null);
|
return get(USER_KEY, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,7 +326,7 @@ class InProcessProtocol extends TestProtocol<Context> {
|
|||||||
throw new ServiceNotAuthorizedException();
|
throw new ServiceNotAuthorizedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
IdentifiedUser user = (IdentifiedUser) ctl.getCurrentUser();
|
IdentifiedUser user = (IdentifiedUser) ctl.getUser();
|
||||||
rp.setRefLogIdent(user.newRefLogIdent());
|
rp.setRefLogIdent(user.newRefLogIdent());
|
||||||
rp.setTimeout(config.getTimeout());
|
rp.setTimeout(config.getTimeout());
|
||||||
rp.setMaxObjectSizeLimit(config.getMaxObjectSizeLimit());
|
rp.setMaxObjectSizeLimit(config.getMaxObjectSizeLimit());
|
||||||
|
@@ -376,7 +376,7 @@ public class AccountIT extends AbstractDaemonTest {
|
|||||||
|
|
||||||
// Check raw external IDs.
|
// Check raw external IDs.
|
||||||
Account.Id currAccountId =
|
Account.Id currAccountId =
|
||||||
((IdentifiedUser) atrScope.get().getCurrentUser()).getAccountId();
|
((IdentifiedUser) atrScope.get().getUser()).getAccountId();
|
||||||
assertThat(
|
assertThat(
|
||||||
GpgKeys.getGpgExtIds(db, currAccountId)
|
GpgKeys.getGpgExtIds(db, currAccountId)
|
||||||
.transform(new Function<AccountExternalId, String>() {
|
.transform(new Function<AccountExternalId, String>() {
|
||||||
|
@@ -126,7 +126,7 @@ public class GerritPublicKeyCheckerTest {
|
|||||||
|
|
||||||
requestContext.setContext(new RequestContext() {
|
requestContext.setContext(new RequestContext() {
|
||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -136,7 +136,7 @@ public abstract class CacheBasedWebSession implements WebSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
if (isSignedIn()) {
|
if (isSignedIn()) {
|
||||||
user = identified.create(val.getAccountId());
|
user = identified.create(val.getAccountId());
|
||||||
|
@@ -177,7 +177,7 @@ public class GitOverHttpServlet extends GitServlet {
|
|||||||
throw new RepositoryNotFoundException(projectName);
|
throw new RepositoryNotFoundException(projectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentUser user = pc.getCurrentUser();
|
CurrentUser user = pc.getUser();
|
||||||
user.setAccessPath(AccessPath.GIT);
|
user.setAccessPath(AccessPath.GIT);
|
||||||
|
|
||||||
if (!pc.isVisible()) {
|
if (!pc.isVisible()) {
|
||||||
@@ -292,12 +292,12 @@ public class GitOverHttpServlet extends GitServlet {
|
|||||||
throws ServiceNotAuthorizedException {
|
throws ServiceNotAuthorizedException {
|
||||||
final ProjectControl pc = (ProjectControl) req.getAttribute(ATT_CONTROL);
|
final ProjectControl pc = (ProjectControl) req.getAttribute(ATT_CONTROL);
|
||||||
|
|
||||||
if (!(pc.getCurrentUser().isIdentifiedUser())) {
|
if (!(pc.getUser().isIdentifiedUser())) {
|
||||||
// Anonymous users are not permitted to push.
|
// Anonymous users are not permitted to push.
|
||||||
throw new ServiceNotAuthorizedException();
|
throw new ServiceNotAuthorizedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
final IdentifiedUser user = (IdentifiedUser) pc.getCurrentUser();
|
final IdentifiedUser user = (IdentifiedUser) pc.getUser();
|
||||||
final ReceiveCommits rc = factory.create(pc, db).getReceiveCommits();
|
final ReceiveCommits rc = factory.create(pc, db).getReceiveCommits();
|
||||||
ReceivePack rp = rc.getReceivePack();
|
ReceivePack rp = rc.getReceivePack();
|
||||||
rp.setRefLogIdent(user.newRefLogIdent());
|
rp.setRefLogIdent(user.newRefLogIdent());
|
||||||
@@ -367,13 +367,13 @@ public class GitOverHttpServlet extends GitServlet {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(pc.getCurrentUser().isIdentifiedUser())) {
|
if (!(pc.getUser().isIdentifiedUser())) {
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AdvertisedObjectsCacheKey cacheKey = AdvertisedObjectsCacheKey.create(
|
AdvertisedObjectsCacheKey cacheKey = AdvertisedObjectsCacheKey.create(
|
||||||
((IdentifiedUser) pc.getCurrentUser()).getAccountId(),
|
((IdentifiedUser) pc.getUser()).getAccountId(),
|
||||||
projectName);
|
projectName);
|
||||||
|
|
||||||
if (isGet) {
|
if (isGet) {
|
||||||
|
@@ -78,7 +78,7 @@ public class HttpLogoutServlet extends HttpServlet {
|
|||||||
final HttpServletResponse rsp) throws IOException {
|
final HttpServletResponse rsp) throws IOException {
|
||||||
|
|
||||||
final String sid = webSession.get().getSessionId();
|
final String sid = webSession.get().getSessionId();
|
||||||
final CurrentUser currentUser = webSession.get().getCurrentUser();
|
final CurrentUser currentUser = webSession.get().getUser();
|
||||||
final String what = "sign out";
|
final String what = "sign out";
|
||||||
final long when = TimeUtil.nowMs();
|
final long when = TimeUtil.nowMs();
|
||||||
|
|
||||||
|
@@ -34,8 +34,8 @@ class HttpRequestContext implements RequestContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
return session.get().getCurrentUser();
|
return session.get().getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -84,7 +84,7 @@ class RunAsFilter implements Filter {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentUser self = session.get().getCurrentUser();
|
CurrentUser self = session.get().getUser();
|
||||||
if (!self.getCapabilities().canRunAs()) {
|
if (!self.getCapabilities().canRunAs()) {
|
||||||
replyError(req, res,
|
replyError(req, res,
|
||||||
SC_FORBIDDEN,
|
SC_FORBIDDEN,
|
||||||
|
@@ -25,7 +25,7 @@ public interface WebSession {
|
|||||||
public String getXGerritAuth();
|
public String getXGerritAuth();
|
||||||
public boolean isValidXGerritAuth(String keyIn);
|
public boolean isValidXGerritAuth(String keyIn);
|
||||||
public AccountExternalId.Key getLastLoginExternalId();
|
public AccountExternalId.Key getLastLoginExternalId();
|
||||||
public CurrentUser getCurrentUser();
|
public CurrentUser getUser();
|
||||||
public void login(AuthResult res, boolean rememberMe);
|
public void login(AuthResult res, boolean rememberMe);
|
||||||
|
|
||||||
/** Set the user account for this current request only. */
|
/** Set the user account for this current request only. */
|
||||||
|
@@ -551,8 +551,8 @@ class GitwebServlet extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String remoteUser = null;
|
String remoteUser = null;
|
||||||
if (project.getCurrentUser().isIdentifiedUser()) {
|
if (project.getUser().isIdentifiedUser()) {
|
||||||
final IdentifiedUser u = (IdentifiedUser) project.getCurrentUser();
|
final IdentifiedUser u = (IdentifiedUser) project.getUser();
|
||||||
final String user = u.getUserName();
|
final String user = u.getUserName();
|
||||||
env.set("GERRIT_USER_NAME", user);
|
env.set("GERRIT_USER_NAME", user);
|
||||||
if (user != null && !user.isEmpty()) {
|
if (user != null && !user.isEmpty()) {
|
||||||
|
@@ -48,7 +48,7 @@ public class BaseServiceImplementation {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CurrentUser getCurrentUser() {
|
protected CurrentUser getUser() {
|
||||||
return currentUser.get();
|
return currentUser.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -134,7 +134,7 @@ final class GerritJsonServlet extends JsonServlet<GerritJsonServlet.GerritCall>
|
|||||||
Audit note = method.getAnnotation(Audit.class);
|
Audit note = method.getAnnotation(Audit.class);
|
||||||
if (note != null) {
|
if (note != null) {
|
||||||
final String sid = call.getWebSession().getSessionId();
|
final String sid = call.getWebSession().getSessionId();
|
||||||
final CurrentUser username = call.getWebSession().getCurrentUser();
|
final CurrentUser username = call.getWebSession().getUser();
|
||||||
final Multimap<String, ?> args =
|
final Multimap<String, ?> args =
|
||||||
extractParams(note, call);
|
extractParams(note, call);
|
||||||
final String what = extractWhat(note, call);
|
final String what = extractWhat(note, call);
|
||||||
@@ -275,7 +275,7 @@ final class GerritJsonServlet extends JsonServlet<GerritJsonServlet.GerritCall>
|
|||||||
} else if (session.isSignedIn() && session.isValidXGerritAuth(keyIn)) {
|
} else if (session.isSignedIn() && session.isValidXGerritAuth(keyIn)) {
|
||||||
// The session must exist, and must be using this token.
|
// The session must exist, and must be using this token.
|
||||||
//
|
//
|
||||||
session.getCurrentUser().setAccessPath(AccessPath.JSON_RPC);
|
session.getUser().setAccessPath(AccessPath.JSON_RPC);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@@ -141,7 +141,7 @@ class AccountServiceImpl extends BaseServiceImplementation implements
|
|||||||
|
|
||||||
AccountProjectWatch watch =
|
AccountProjectWatch watch =
|
||||||
new AccountProjectWatch(new AccountProjectWatch.Key(
|
new AccountProjectWatch(new AccountProjectWatch.Key(
|
||||||
((IdentifiedUser) ctl.getCurrentUser()).getAccountId(),
|
((IdentifiedUser) ctl.getUser()).getAccountId(),
|
||||||
nameKey, filter));
|
nameKey, filter));
|
||||||
try {
|
try {
|
||||||
db.accountProjectWatches().insert(Collections.singleton(watch));
|
db.accountProjectWatches().insert(Collections.singleton(watch));
|
||||||
|
@@ -177,7 +177,7 @@ class PatchSetDetailFactory extends Handler<PatchSetDetail> {
|
|||||||
detail.setInfo(infoFactory.get(db, patchSet.getId()));
|
detail.setInfo(infoFactory.get(db, patchSet.getId()));
|
||||||
detail.setPatches(patches);
|
detail.setPatches(patches);
|
||||||
|
|
||||||
final CurrentUser user = control.getCurrentUser();
|
final CurrentUser user = control.getUser();
|
||||||
if (user.isIdentifiedUser() && edit == null) {
|
if (user.isIdentifiedUser() && edit == null) {
|
||||||
// If we are signed in, compute the number of draft comments by the
|
// If we are signed in, compute the number of draft comments by the
|
||||||
// current user on each of these patch files. This way they can more
|
// current user on each of these patch files. This way they can more
|
||||||
|
@@ -60,7 +60,7 @@ class PatchDetailServiceImpl extends BaseServiceImplementation implements
|
|||||||
public PatchScript call() throws Exception {
|
public PatchScript call() throws Exception {
|
||||||
ChangeControl control = changeControlFactory.validateFor(
|
ChangeControl control = changeControlFactory.validateFor(
|
||||||
patchKey.getParentKey().getParentKey(),
|
patchKey.getParentKey().getParentKey(),
|
||||||
getCurrentUser());
|
getUser());
|
||||||
return patchScriptFactoryFactory.create(
|
return patchScriptFactoryFactory.create(
|
||||||
control, patchKey.getFileName(), psa, psb, dp).call();
|
control, patchKey.getFileName(), psa, psb, dp).call();
|
||||||
}
|
}
|
||||||
|
@@ -131,7 +131,7 @@ public class ReviewProjectAccess extends ProjectAccessHandler<Change.Id> {
|
|||||||
try (RevWalk rw = new RevWalk(md.getRepository());
|
try (RevWalk rw = new RevWalk(md.getRepository());
|
||||||
ObjectInserter objInserter = md.getRepository().newObjectInserter();
|
ObjectInserter objInserter = md.getRepository().newObjectInserter();
|
||||||
BatchUpdate bu = updateFactory.create(
|
BatchUpdate bu = updateFactory.create(
|
||||||
db, change.getProject(), ctl.getCurrentUser(),
|
db, change.getProject(), ctl.getUser(),
|
||||||
change.getCreatedOn())) {
|
change.getCreatedOn())) {
|
||||||
bu.setRepository(md.getRepository(), rw, objInserter);
|
bu.setRepository(md.getRepository(), rw, objInserter);
|
||||||
bu.insertChange(
|
bu.insertChange(
|
||||||
|
@@ -288,7 +288,7 @@ public class ChangeUtil {
|
|||||||
.append(change.getKey().get());
|
.append(change.getKey().get());
|
||||||
ins.setMessage(msgBuf.toString());
|
ins.setMessage(msgBuf.toString());
|
||||||
try (BatchUpdate bu = updateFactory.create(
|
try (BatchUpdate bu = updateFactory.create(
|
||||||
db.get(), change.getProject(), refControl.getCurrentUser(),
|
db.get(), change.getProject(), refControl.getUser(),
|
||||||
change.getCreatedOn())) {
|
change.getCreatedOn())) {
|
||||||
bu.setRepository(git, revWalk, oi);
|
bu.setRepository(git, revWalk, oi);
|
||||||
bu.insertChange(ins);
|
bu.insertChange(ins);
|
||||||
|
@@ -58,7 +58,7 @@ public class CapabilityControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Identity of the user the control will compute for. */
|
/** Identity of the user the control will compute for. */
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -121,7 +121,7 @@ public class GroupControl {
|
|||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,8 +144,8 @@ public class GroupControl {
|
|||||||
isOwner = false;
|
isOwner = false;
|
||||||
} else if (isOwner == null) {
|
} else if (isOwner == null) {
|
||||||
AccountGroup.UUID ownerUUID = accountGroup.getOwnerGroupUUID();
|
AccountGroup.UUID ownerUUID = accountGroup.getOwnerGroupUUID();
|
||||||
isOwner = getCurrentUser().getEffectiveGroups().contains(ownerUUID)
|
isOwner = getUser().getEffectiveGroups().contains(ownerUUID)
|
||||||
|| getCurrentUser().getCapabilities().canAdministrateServer();
|
|| getUser().getCapabilities().canAdministrateServer();
|
||||||
}
|
}
|
||||||
return isOwner;
|
return isOwner;
|
||||||
}
|
}
|
||||||
|
@@ -81,7 +81,7 @@ public class Abandon implements RestModifyView<ChangeResource, AbandonInput>,
|
|||||||
final AbandonInput input)
|
final AbandonInput input)
|
||||||
throws RestApiException, UpdateException, OrmException {
|
throws RestApiException, UpdateException, OrmException {
|
||||||
ChangeControl control = req.getControl();
|
ChangeControl control = req.getControl();
|
||||||
IdentifiedUser caller = (IdentifiedUser) control.getCurrentUser();
|
IdentifiedUser caller = (IdentifiedUser) control.getUser();
|
||||||
if (!control.canAbandon()) {
|
if (!control.canAbandon()) {
|
||||||
throw new AuthException("abandon not permitted");
|
throw new AuthException("abandon not permitted");
|
||||||
}
|
}
|
||||||
@@ -95,7 +95,7 @@ public class Abandon implements RestModifyView<ChangeResource, AbandonInput>,
|
|||||||
Op op = new Op(msgTxt, account);
|
Op op = new Op(msgTxt, account);
|
||||||
Change c = control.getChange();
|
Change c = control.getChange();
|
||||||
try (BatchUpdate u = batchUpdateFactory.create(dbProvider.get(),
|
try (BatchUpdate u = batchUpdateFactory.create(dbProvider.get(),
|
||||||
c.getProject(), control.getCurrentUser(), TimeUtil.nowTs())) {
|
c.getProject(), control.getUser(), TimeUtil.nowTs())) {
|
||||||
u.addOp(c.getId(), op).execute();
|
u.addOp(c.getId(), op).execute();
|
||||||
}
|
}
|
||||||
return op.change;
|
return op.change;
|
||||||
|
@@ -62,11 +62,11 @@ public class ActionJson {
|
|||||||
|
|
||||||
private Map<String, ActionInfo> toActionMap(ChangeControl ctl) {
|
private Map<String, ActionInfo> toActionMap(ChangeControl ctl) {
|
||||||
Map<String, ActionInfo> out = new LinkedHashMap<>();
|
Map<String, ActionInfo> out = new LinkedHashMap<>();
|
||||||
if (!ctl.getCurrentUser().isIdentifiedUser()) {
|
if (!ctl.getUser().isIdentifiedUser()) {
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
Provider<CurrentUser> userProvider = Providers.of(ctl.getCurrentUser());
|
Provider<CurrentUser> userProvider = Providers.of(ctl.getUser());
|
||||||
for (UiAction.Description d : UiActions.from(
|
for (UiAction.Description d : UiActions.from(
|
||||||
changeViews,
|
changeViews,
|
||||||
new ChangeResource(ctl),
|
new ChangeResource(ctl),
|
||||||
@@ -89,9 +89,9 @@ public class ActionJson {
|
|||||||
|
|
||||||
private Map<String, ActionInfo> toActionMap(RevisionResource rsrc) {
|
private Map<String, ActionInfo> toActionMap(RevisionResource rsrc) {
|
||||||
Map<String, ActionInfo> out = new LinkedHashMap<>();
|
Map<String, ActionInfo> out = new LinkedHashMap<>();
|
||||||
if (rsrc.getControl().getCurrentUser().isIdentifiedUser()) {
|
if (rsrc.getControl().getUser().isIdentifiedUser()) {
|
||||||
Provider<CurrentUser> userProvider = Providers.of(
|
Provider<CurrentUser> userProvider = Providers.of(
|
||||||
rsrc.getControl().getCurrentUser());
|
rsrc.getControl().getUser());
|
||||||
for (UiAction.Description d : UiActions.from(
|
for (UiAction.Description d : UiActions.from(
|
||||||
revisions, rsrc, userProvider)) {
|
revisions, rsrc, userProvider)) {
|
||||||
out.put(d.getId(), new ActionInfo(d));
|
out.put(d.getId(), new ActionInfo(d));
|
||||||
|
@@ -149,9 +149,9 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static IdentifiedUser checkUser(RefControl ctl) {
|
private static IdentifiedUser checkUser(RefControl ctl) {
|
||||||
checkArgument(ctl.getCurrentUser().isIdentifiedUser(),
|
checkArgument(ctl.getUser().isIdentifiedUser(),
|
||||||
"only IdentifiedUser may create change");
|
"only IdentifiedUser may create change");
|
||||||
return (IdentifiedUser) ctl.getCurrentUser();
|
return (IdentifiedUser) ctl.getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -308,7 +308,7 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
|
|||||||
hooks.doPatchsetCreatedHook(change, patchSet, db);
|
hooks.doPatchsetCreatedHook(change, patchSet, db);
|
||||||
if (approvals != null && !approvals.isEmpty()) {
|
if (approvals != null && !approvals.isEmpty()) {
|
||||||
hooks.doCommentAddedHook(change,
|
hooks.doCommentAddedHook(change,
|
||||||
((IdentifiedUser) refControl.getCurrentUser()).getAccount(),
|
((IdentifiedUser) refControl.getUser()).getAccount(),
|
||||||
patchSet, null, approvals, db);
|
patchSet, null, approvals, db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -91,7 +91,7 @@ public class ChangeResource implements RestResource, HasETag {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getETag() {
|
public String getETag() {
|
||||||
CurrentUser user = control.getCurrentUser();
|
CurrentUser user = control.getUser();
|
||||||
Hasher h = Hashing.md5().newHasher()
|
Hasher h = Hashing.md5().newHasher()
|
||||||
.putBoolean(user.getStarredChanges().contains(getChange().getId()));
|
.putBoolean(user.getStarredChanges().contains(getChange().getId()));
|
||||||
prepareETag(h, user);
|
prepareETag(h, user);
|
||||||
|
@@ -47,7 +47,7 @@ public class Check implements RestReadView<ChangeResource>,
|
|||||||
ChangeControl ctl = rsrc.getControl();
|
ChangeControl ctl = rsrc.getControl();
|
||||||
if (!ctl.isOwner()
|
if (!ctl.isOwner()
|
||||||
&& !ctl.getProjectControl().isOwner()
|
&& !ctl.getProjectControl().isOwner()
|
||||||
&& !ctl.getCurrentUser().getCapabilities().canMaintainServer()) {
|
&& !ctl.getUser().getCapabilities().canMaintainServer()) {
|
||||||
throw new AuthException("Cannot fix change");
|
throw new AuthException("Cannot fix change");
|
||||||
}
|
}
|
||||||
return Response.withMustRevalidate(newChangeJson().fix(input).format(rsrc));
|
return Response.withMustRevalidate(newChangeJson().fix(input).format(rsrc));
|
||||||
|
@@ -111,7 +111,7 @@ public class DeleteReviewer implements RestModifyView<ReviewerResource, Input> {
|
|||||||
ChangeMessage changeMessage =
|
ChangeMessage changeMessage =
|
||||||
new ChangeMessage(new ChangeMessage.Key(rsrc.getChange().getId(),
|
new ChangeMessage(new ChangeMessage.Key(rsrc.getChange().getId(),
|
||||||
ChangeUtil.messageUUID(db)),
|
ChangeUtil.messageUUID(db)),
|
||||||
((IdentifiedUser) control.getCurrentUser()).getAccountId(),
|
((IdentifiedUser) control.getUser()).getAccountId(),
|
||||||
TimeUtil.nowTs(), rsrc.getChange().currentPatchSetId());
|
TimeUtil.nowTs(), rsrc.getChange().currentPatchSetId());
|
||||||
changeMessage.setMessage(msg.toString());
|
changeMessage.setMessage(msg.toString());
|
||||||
cmUtil.addChangeMessage(db, update, changeMessage);
|
cmUtil.addChangeMessage(db, update, changeMessage);
|
||||||
|
@@ -57,6 +57,6 @@ public class DraftCommentResource implements RestResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Account.Id getAuthorId() {
|
Account.Id getAuthorId() {
|
||||||
return ((IdentifiedUser) getControl().getCurrentUser()).getAccountId();
|
return ((IdentifiedUser) getControl().getUser()).getAccountId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -128,7 +128,7 @@ public class EmailReviewComments implements Runnable, RequestContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
throw new OutOfScopeException("No user on email thread");
|
throw new OutOfScopeException("No user on email thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -63,7 +63,7 @@ public class GetRevisionActions implements ETagView<RevisionResource> {
|
|||||||
@Override
|
@Override
|
||||||
public String getETag(RevisionResource rsrc) {
|
public String getETag(RevisionResource rsrc) {
|
||||||
Hasher h = Hashing.md5().newHasher();
|
Hasher h = Hashing.md5().newHasher();
|
||||||
CurrentUser user = rsrc.getControl().getCurrentUser();
|
CurrentUser user = rsrc.getControl().getUser();
|
||||||
try {
|
try {
|
||||||
rsrc.getChangeResource().prepareETag(h, user);
|
rsrc.getChangeResource().prepareETag(h, user);
|
||||||
h.putBoolean(Submit.wholeTopicEnabled(config));
|
h.putBoolean(Submit.wholeTopicEnabled(config));
|
||||||
|
@@ -47,7 +47,7 @@ public class Index implements RestModifyView<ChangeResource, Input> {
|
|||||||
throws IOException, AuthException {
|
throws IOException, AuthException {
|
||||||
ChangeControl ctl = rsrc.getControl();
|
ChangeControl ctl = rsrc.getControl();
|
||||||
if (!ctl.isOwner()
|
if (!ctl.isOwner()
|
||||||
&& !ctl.getCurrentUser().getCapabilities().canMaintainServer()) {
|
&& !ctl.getUser().getCapabilities().canMaintainServer()) {
|
||||||
throw new AuthException(
|
throw new AuthException(
|
||||||
"Only change owner or server maintainer can reindex");
|
"Only change owner or server maintainer can reindex");
|
||||||
}
|
}
|
||||||
|
@@ -51,10 +51,10 @@ public class ListChangeDrafts implements RestReadView<ChangeResource> {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, List<CommentInfo>> apply(
|
public Map<String, List<CommentInfo>> apply(
|
||||||
ChangeResource rsrc) throws AuthException, OrmException {
|
ChangeResource rsrc) throws AuthException, OrmException {
|
||||||
if (!rsrc.getControl().getCurrentUser().isIdentifiedUser()) {
|
if (!rsrc.getControl().getUser().isIdentifiedUser()) {
|
||||||
throw new AuthException("Authentication required");
|
throw new AuthException("Authentication required");
|
||||||
}
|
}
|
||||||
IdentifiedUser user = (IdentifiedUser) rsrc.getControl().getCurrentUser();
|
IdentifiedUser user = (IdentifiedUser) rsrc.getControl().getUser();
|
||||||
ChangeData cd = changeDataFactory.create(db.get(), rsrc.getControl());
|
ChangeData cd = changeDataFactory.create(db.get(), rsrc.getControl());
|
||||||
List<PatchLineComment> drafts =
|
List<PatchLineComment> drafts =
|
||||||
plcUtil.draftByChangeAuthor(db.get(), cd.notes(), user.getAccountId());
|
plcUtil.draftByChangeAuthor(db.get(), cd.notes(), user.getAccountId());
|
||||||
|
@@ -145,10 +145,10 @@ public class PatchSetInserter extends BatchUpdate.Op {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static IdentifiedUser checkUser(ChangeControl ctl) {
|
private static IdentifiedUser checkUser(ChangeControl ctl) {
|
||||||
checkArgument(ctl.getCurrentUser().isIdentifiedUser(),
|
checkArgument(ctl.getUser().isIdentifiedUser(),
|
||||||
"only IdentifiedUser may create patch set on change %s",
|
"only IdentifiedUser may create patch set on change %s",
|
||||||
ctl.getChange().getId());
|
ctl.getChange().getId());
|
||||||
return (IdentifiedUser) ctl.getCurrentUser();
|
return (IdentifiedUser) ctl.getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatchSet.Id getPatchSetId() throws IOException {
|
public PatchSet.Id getPatchSetId() throws IOException {
|
||||||
|
@@ -49,7 +49,7 @@ public class PostHashtags
|
|||||||
public Response<ImmutableSortedSet<String>> apply(ChangeResource req,
|
public Response<ImmutableSortedSet<String>> apply(ChangeResource req,
|
||||||
HashtagsInput input) throws RestApiException, UpdateException {
|
HashtagsInput input) throws RestApiException, UpdateException {
|
||||||
try (BatchUpdate bu = batchUpdateFactory.create(db.get(),
|
try (BatchUpdate bu = batchUpdateFactory.create(db.get(),
|
||||||
req.getChange().getProject(), req.getControl().getCurrentUser(),
|
req.getChange().getProject(), req.getControl().getUser(),
|
||||||
TimeUtil.nowTs())) {
|
TimeUtil.nowTs())) {
|
||||||
SetHashtagsOp op = hashtagsFactory.create(input);
|
SetHashtagsOp op = hashtagsFactory.create(input);
|
||||||
bu.addOp(req.getChange().getId(), op);
|
bu.addOp(req.getChange().getId(), op);
|
||||||
|
@@ -175,7 +175,7 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
|
|||||||
ChangeControl control = rsrc.getControl();
|
ChangeControl control = rsrc.getControl();
|
||||||
Set<Account> members;
|
Set<Account> members;
|
||||||
try {
|
try {
|
||||||
members = groupMembersFactory.create(control.getCurrentUser()).listAccounts(
|
members = groupMembersFactory.create(control.getUser()).listAccounts(
|
||||||
group.getGroupUUID(), control.getProject().getNameKey());
|
group.getGroupUUID(), control.getProject().getNameKey());
|
||||||
} catch (NoSuchGroupException e) {
|
} catch (NoSuchGroupException e) {
|
||||||
throw new UnprocessableEntityException(e.getMessage());
|
throw new UnprocessableEntityException(e.getMessage());
|
||||||
|
@@ -78,7 +78,7 @@ public class PutTopic implements RestModifyView<ChangeResource, Input>,
|
|||||||
|
|
||||||
Op op = new Op(ctl, input != null ? input : new Input());
|
Op op = new Op(ctl, input != null ? input : new Input());
|
||||||
try (BatchUpdate u = batchUpdateFactory.create(dbProvider.get(),
|
try (BatchUpdate u = batchUpdateFactory.create(dbProvider.get(),
|
||||||
req.getChange().getProject(), ctl.getCurrentUser(), TimeUtil.nowTs())) {
|
req.getChange().getProject(), ctl.getUser(), TimeUtil.nowTs())) {
|
||||||
u.addOp(req.getChange().getId(), op);
|
u.addOp(req.getChange().getId(), op);
|
||||||
u.execute();
|
u.execute();
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ public class PutTopic implements RestModifyView<ChangeResource, Input>,
|
|||||||
|
|
||||||
public Op(ChangeControl ctl, Input input) {
|
public Op(ChangeControl ctl, Input input) {
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.caller = (IdentifiedUser) ctl.getCurrentUser();
|
this.caller = (IdentifiedUser) ctl.getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -120,7 +120,7 @@ public class RebaseChange {
|
|||||||
UpdateException, RestApiException {
|
UpdateException, RestApiException {
|
||||||
Change change = rsrc.getChange();
|
Change change = rsrc.getChange();
|
||||||
PatchSet patchSet = rsrc.getPatchSet();
|
PatchSet patchSet = rsrc.getPatchSet();
|
||||||
IdentifiedUser uploader = (IdentifiedUser) rsrc.getControl().getCurrentUser();
|
IdentifiedUser uploader = (IdentifiedUser) rsrc.getControl().getUser();
|
||||||
|
|
||||||
try (ObjectInserter inserter = git.newObjectInserter()) {
|
try (ObjectInserter inserter = git.newObjectInserter()) {
|
||||||
String baseRev = newBaseRev;
|
String baseRev = newBaseRev;
|
||||||
|
@@ -88,7 +88,7 @@ public class Restore implements RestModifyView<ChangeResource, RestoreInput>,
|
|||||||
|
|
||||||
Op op = new Op(input);
|
Op op = new Op(input);
|
||||||
try (BatchUpdate u = batchUpdateFactory.create(dbProvider.get(),
|
try (BatchUpdate u = batchUpdateFactory.create(dbProvider.get(),
|
||||||
req.getChange().getProject(), ctl.getCurrentUser(), TimeUtil.nowTs())) {
|
req.getChange().getProject(), ctl.getUser(), TimeUtil.nowTs())) {
|
||||||
u.addOp(req.getChange().getId(), op).execute();
|
u.addOp(req.getChange().getId(), op).execute();
|
||||||
}
|
}
|
||||||
return json.create(ChangeJson.NO_OPTIONS).format(op.change);
|
return json.create(ChangeJson.NO_OPTIONS).format(op.change);
|
||||||
|
@@ -84,7 +84,7 @@ public class RevisionResource implements RestResource, HasETag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IdentifiedUser getUser() {
|
IdentifiedUser getUser() {
|
||||||
return (IdentifiedUser) getControl().getCurrentUser();
|
return (IdentifiedUser) getControl().getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
RevisionResource doNotCache() {
|
RevisionResource doNotCache() {
|
||||||
|
@@ -165,7 +165,7 @@ public class Submit implements RestModifyView<RevisionResource, SubmitInput>,
|
|||||||
rsrc = onBehalfOf(rsrc, input);
|
rsrc = onBehalfOf(rsrc, input);
|
||||||
}
|
}
|
||||||
ChangeControl control = rsrc.getControl();
|
ChangeControl control = rsrc.getControl();
|
||||||
IdentifiedUser caller = (IdentifiedUser) control.getCurrentUser();
|
IdentifiedUser caller = (IdentifiedUser) control.getUser();
|
||||||
Change change = rsrc.getChange();
|
Change change = rsrc.getChange();
|
||||||
if (input.onBehalfOf == null && !control.canSubmit()) {
|
if (input.onBehalfOf == null && !control.canSubmit()) {
|
||||||
throw new AuthException("submit not permitted");
|
throw new AuthException("submit not permitted");
|
||||||
|
@@ -239,7 +239,7 @@ public class ChangeEditUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try (BatchUpdate bu = updateFactory.create(
|
try (BatchUpdate bu = updateFactory.create(
|
||||||
db.get(), change.getProject(), ctl.getCurrentUser(),
|
db.get(), change.getProject(), ctl.getUser(),
|
||||||
TimeUtil.nowTs())) {
|
TimeUtil.nowTs())) {
|
||||||
bu.addOp(change.getId(), inserter
|
bu.addOp(change.getId(), inserter
|
||||||
.setDraft(change.getStatus() == Status.DRAFT ||
|
.setDraft(change.getStatus() == Status.DRAFT ||
|
||||||
|
@@ -96,7 +96,7 @@ public class EmailMerge implements Runnable, RequestContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
throw new OutOfScopeException("No user on email thread");
|
throw new OutOfScopeException("No user on email thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -390,7 +390,7 @@ public class ReceiveCommits {
|
|||||||
final ChangeEditUtil editUtil,
|
final ChangeEditUtil editUtil,
|
||||||
final BatchUpdate.Factory batchUpdateFactory,
|
final BatchUpdate.Factory batchUpdateFactory,
|
||||||
final SetHashtagsOp.Factory hashtagsFactory) throws IOException {
|
final SetHashtagsOp.Factory hashtagsFactory) throws IOException {
|
||||||
this.currentUser = (IdentifiedUser) projectControl.getCurrentUser();
|
this.currentUser = (IdentifiedUser) projectControl.getUser();
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.queryProvider = queryProvider;
|
this.queryProvider = queryProvider;
|
||||||
this.changeDataFactory = changeDataFactory;
|
this.changeDataFactory = changeDataFactory;
|
||||||
@@ -1809,7 +1809,7 @@ public class ReceiveCommits {
|
|||||||
RevisionResource rsrc = new RevisionResource(changes.parse(changeCtl), ps);
|
RevisionResource rsrc = new RevisionResource(changes.parse(changeCtl), ps);
|
||||||
try {
|
try {
|
||||||
mergeOpProvider.get().merge(db, rsrc.getChange(),
|
mergeOpProvider.get().merge(db, rsrc.getChange(),
|
||||||
(IdentifiedUser) changeCtl.getCurrentUser(), false);
|
(IdentifiedUser) changeCtl.getUser(), false);
|
||||||
} catch (NoSuchChangeException e) {
|
} catch (NoSuchChangeException e) {
|
||||||
throw new OrmException(e);
|
throw new OrmException(e);
|
||||||
}
|
}
|
||||||
|
@@ -79,8 +79,8 @@ public class VisibleRefFilter extends AbstractAdvertiseRefsHook {
|
|||||||
|
|
||||||
Account.Id currAccountId;
|
Account.Id currAccountId;
|
||||||
boolean canViewMetadata;
|
boolean canViewMetadata;
|
||||||
if (projectCtl.getCurrentUser().isIdentifiedUser()) {
|
if (projectCtl.getUser().isIdentifiedUser()) {
|
||||||
IdentifiedUser user = ((IdentifiedUser) projectCtl.getCurrentUser());
|
IdentifiedUser user = ((IdentifiedUser) projectCtl.getUser());
|
||||||
currAccountId = user.getAccountId();
|
currAccountId = user.getAccountId();
|
||||||
canViewMetadata = user.getCapabilities().canAccessDatabase();
|
canViewMetadata = user.getCapabilities().canAccessDatabase();
|
||||||
} else {
|
} else {
|
||||||
|
@@ -193,7 +193,7 @@ public class CommitValidators {
|
|||||||
this.canonicalWebUrl = canonicalWebUrl;
|
this.canonicalWebUrl = canonicalWebUrl;
|
||||||
this.installCommitMsgHookCommand = installCommitMsgHookCommand;
|
this.installCommitMsgHookCommand = installCommitMsgHookCommand;
|
||||||
this.sshInfo = sshInfo;
|
this.sshInfo = sshInfo;
|
||||||
this.user = (IdentifiedUser) projectControl.getCurrentUser();
|
this.user = (IdentifiedUser) projectControl.getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -316,7 +316,7 @@ public class CommitValidators {
|
|||||||
@Override
|
@Override
|
||||||
public List<CommitValidationMessage> onCommitReceived(
|
public List<CommitValidationMessage> onCommitReceived(
|
||||||
CommitReceivedEvent receiveEvent) throws CommitValidationException {
|
CommitReceivedEvent receiveEvent) throws CommitValidationException {
|
||||||
IdentifiedUser currentUser = (IdentifiedUser) refControl.getCurrentUser();
|
IdentifiedUser currentUser = (IdentifiedUser) refControl.getUser();
|
||||||
|
|
||||||
if (REFS_CONFIG.equals(refControl.getRefName())) {
|
if (REFS_CONFIG.equals(refControl.getRefName())) {
|
||||||
List<CommitValidationMessage> messages = new LinkedList<>();
|
List<CommitValidationMessage> messages = new LinkedList<>();
|
||||||
@@ -402,7 +402,7 @@ public class CommitValidators {
|
|||||||
@Override
|
@Override
|
||||||
public List<CommitValidationMessage> onCommitReceived(
|
public List<CommitValidationMessage> onCommitReceived(
|
||||||
CommitReceivedEvent receiveEvent) throws CommitValidationException {
|
CommitReceivedEvent receiveEvent) throws CommitValidationException {
|
||||||
IdentifiedUser currentUser = (IdentifiedUser) refControl.getCurrentUser();
|
IdentifiedUser currentUser = (IdentifiedUser) refControl.getUser();
|
||||||
final PersonIdent committer = receiveEvent.commit.getCommitterIdent();
|
final PersonIdent committer = receiveEvent.commit.getCommitterIdent();
|
||||||
final PersonIdent author = receiveEvent.commit.getAuthorIdent();
|
final PersonIdent author = receiveEvent.commit.getAuthorIdent();
|
||||||
final ProjectControl projectControl = refControl.getProjectControl();
|
final ProjectControl projectControl = refControl.getProjectControl();
|
||||||
@@ -445,7 +445,7 @@ public class CommitValidators {
|
|||||||
@Override
|
@Override
|
||||||
public List<CommitValidationMessage> onCommitReceived(
|
public List<CommitValidationMessage> onCommitReceived(
|
||||||
CommitReceivedEvent receiveEvent) throws CommitValidationException {
|
CommitReceivedEvent receiveEvent) throws CommitValidationException {
|
||||||
IdentifiedUser currentUser = (IdentifiedUser) refControl.getCurrentUser();
|
IdentifiedUser currentUser = (IdentifiedUser) refControl.getUser();
|
||||||
final PersonIdent author = receiveEvent.commit.getAuthorIdent();
|
final PersonIdent author = receiveEvent.commit.getAuthorIdent();
|
||||||
|
|
||||||
if (!currentUser.hasEmailAddress(author.getEmailAddress())
|
if (!currentUser.hasEmailAddress(author.getEmailAddress())
|
||||||
@@ -475,7 +475,7 @@ public class CommitValidators {
|
|||||||
@Override
|
@Override
|
||||||
public List<CommitValidationMessage> onCommitReceived(
|
public List<CommitValidationMessage> onCommitReceived(
|
||||||
CommitReceivedEvent receiveEvent) throws CommitValidationException {
|
CommitReceivedEvent receiveEvent) throws CommitValidationException {
|
||||||
IdentifiedUser currentUser = (IdentifiedUser) refControl.getCurrentUser();
|
IdentifiedUser currentUser = (IdentifiedUser) refControl.getUser();
|
||||||
final PersonIdent committer = receiveEvent.commit.getCommitterIdent();
|
final PersonIdent committer = receiveEvent.commit.getCommitterIdent();
|
||||||
if (!currentUser.hasEmailAddress(committer.getEmailAddress())
|
if (!currentUser.hasEmailAddress(committer.getEmailAddress())
|
||||||
&& !refControl.canForgeCommitter()) {
|
&& !refControl.canForgeCommitter()) {
|
||||||
@@ -560,8 +560,8 @@ public class CommitValidators {
|
|||||||
public List<CommitValidationMessage> onCommitReceived(
|
public List<CommitValidationMessage> onCommitReceived(
|
||||||
CommitReceivedEvent receiveEvent) throws CommitValidationException {
|
CommitReceivedEvent receiveEvent) throws CommitValidationException {
|
||||||
|
|
||||||
if (refControl.getCurrentUser().isIdentifiedUser()) {
|
if (refControl.getUser().isIdentifiedUser()) {
|
||||||
IdentifiedUser user = (IdentifiedUser) refControl.getCurrentUser();
|
IdentifiedUser user = (IdentifiedUser) refControl.getUser();
|
||||||
|
|
||||||
String refname = receiveEvent.refName;
|
String refname = receiveEvent.refName;
|
||||||
ObjectId old = receiveEvent.commit.getParent(0);
|
ObjectId old = receiveEvent.commit.getParent(0);
|
||||||
|
@@ -101,7 +101,7 @@ public class AddIncludedGroups implements RestModifyView<GroupResource, Input> {
|
|||||||
GroupControl control = resource.getControl();
|
GroupControl control = resource.getControl();
|
||||||
Map<AccountGroup.UUID, AccountGroupById> newIncludedGroups = Maps.newHashMap();
|
Map<AccountGroup.UUID, AccountGroupById> newIncludedGroups = Maps.newHashMap();
|
||||||
List<GroupInfo> result = Lists.newLinkedList();
|
List<GroupInfo> result = Lists.newLinkedList();
|
||||||
Account.Id me = ((IdentifiedUser) control.getCurrentUser()).getAccountId();
|
Account.Id me = ((IdentifiedUser) control.getUser()).getAccountId();
|
||||||
|
|
||||||
for (String includedGroup : input.groups) {
|
for (String includedGroup : input.groups) {
|
||||||
GroupDescription.Basic d = groupsCollection.parse(includedGroup);
|
GroupDescription.Basic d = groupsCollection.parse(includedGroup);
|
||||||
|
@@ -231,7 +231,7 @@ public class ChangeIndexer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
throw new OutOfScopeException("No user during ChangeIndexer");
|
throw new OutOfScopeException("No user during ChangeIndexer");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -78,7 +78,7 @@ public abstract class AbstractChangeUpdate extends VersionedMetaData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IdentifiedUser getUser() {
|
public IdentifiedUser getUser() {
|
||||||
return (IdentifiedUser) ctl.getCurrentUser();
|
return (IdentifiedUser) ctl.getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatchSet.Id getPatchSetId() {
|
public PatchSet.Id getPatchSetId() {
|
||||||
|
@@ -93,9 +93,9 @@ public class ChangeDraftUpdate extends AbstractChangeUpdate {
|
|||||||
anonymousCowardName, when);
|
anonymousCowardName, when);
|
||||||
this.draftsProject = allUsers;
|
this.draftsProject = allUsers;
|
||||||
this.commentsUtil = commentsUtil;
|
this.commentsUtil = commentsUtil;
|
||||||
checkState(ctl.getCurrentUser().isIdentifiedUser(),
|
checkState(ctl.getUser().isIdentifiedUser(),
|
||||||
"Current user must be identified");
|
"Current user must be identified");
|
||||||
IdentifiedUser user = (IdentifiedUser) ctl.getCurrentUser();
|
IdentifiedUser user = (IdentifiedUser) ctl.getUser();
|
||||||
this.accountId = user.getAccountId();
|
this.accountId = user.getAccountId();
|
||||||
this.changeNotes = getChangeNotes().load();
|
this.changeNotes = getChangeNotes().load();
|
||||||
this.draftNotes = draftNotesFactory.create(ctl.getChange().getId(),
|
this.draftNotes = draftNotesFactory.create(ctl.getChange().getId(),
|
||||||
|
@@ -314,7 +314,7 @@ public class PatchScriptFactory implements Callable<PatchScript> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CurrentUser user = control.getCurrentUser();
|
final CurrentUser user = control.getUser();
|
||||||
if (user.isIdentifiedUser()) {
|
if (user.isIdentifiedUser()) {
|
||||||
final Account.Id me = ((IdentifiedUser) user).getAccountId();
|
final Account.Id me = ((IdentifiedUser) user).getAccountId();
|
||||||
switch (changeType) {
|
switch (changeType) {
|
||||||
|
@@ -124,7 +124,7 @@ public class ChangeControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ChangeControl forUser(final CurrentUser who) {
|
public ChangeControl forUser(final CurrentUser who) {
|
||||||
if (getCurrentUser().equals(who)) {
|
if (getUser().equals(who)) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
return new ChangeControl(changeDataFactory,
|
return new ChangeControl(changeDataFactory,
|
||||||
@@ -135,8 +135,8 @@ public class ChangeControl {
|
|||||||
return refControl;
|
return refControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
return getRefControl().getCurrentUser();
|
return getRefControl().getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProjectControl getProjectControl() {
|
public ProjectControl getProjectControl() {
|
||||||
@@ -182,7 +182,7 @@ public class ChangeControl {
|
|||||||
return isOwner() // owner (aka creator) of the change can abandon
|
return isOwner() // owner (aka creator) of the change can abandon
|
||||||
|| getRefControl().isOwner() // branch owner can abandon
|
|| getRefControl().isOwner() // branch owner can abandon
|
||||||
|| getProjectControl().isOwner() // project owner can abandon
|
|| getProjectControl().isOwner() // project owner can abandon
|
||||||
|| getCurrentUser().getCapabilities().canAdministrateServer() // site administers are god
|
|| getUser().getCapabilities().canAdministrateServer() // site administers are god
|
||||||
|| getRefControl().canAbandon() // user can abandon a specific ref
|
|| getRefControl().canAbandon() // user can abandon a specific ref
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
@@ -252,8 +252,8 @@ public class ChangeControl {
|
|||||||
|
|
||||||
/** Is this user the owner of the change? */
|
/** Is this user the owner of the change? */
|
||||||
public boolean isOwner() {
|
public boolean isOwner() {
|
||||||
if (getCurrentUser().isIdentifiedUser()) {
|
if (getUser().isIdentifiedUser()) {
|
||||||
final IdentifiedUser i = (IdentifiedUser) getCurrentUser();
|
final IdentifiedUser i = (IdentifiedUser) getUser();
|
||||||
return i.getAccountId().equals(getChange().getOwner());
|
return i.getAccountId().equals(getChange().getOwner());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -267,9 +267,9 @@ public class ChangeControl {
|
|||||||
/** Is this user a reviewer for the change? */
|
/** Is this user a reviewer for the change? */
|
||||||
public boolean isReviewer(ReviewDb db, @Nullable ChangeData cd)
|
public boolean isReviewer(ReviewDb db, @Nullable ChangeData cd)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
if (getCurrentUser().isIdentifiedUser()) {
|
if (getUser().isIdentifiedUser()) {
|
||||||
Collection<Account.Id> results = changeData(db, cd).reviewers().values();
|
Collection<Account.Id> results = changeData(db, cd).reviewers().values();
|
||||||
IdentifiedUser user = (IdentifiedUser) getCurrentUser();
|
IdentifiedUser user = (IdentifiedUser) getUser();
|
||||||
return results.contains(user.getAccountId());
|
return results.contains(user.getAccountId());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -284,8 +284,8 @@ public class ChangeControl {
|
|||||||
if (getChange().getStatus().isOpen()) {
|
if (getChange().getStatus().isOpen()) {
|
||||||
// A user can always remove themselves.
|
// A user can always remove themselves.
|
||||||
//
|
//
|
||||||
if (getCurrentUser().isIdentifiedUser()) {
|
if (getUser().isIdentifiedUser()) {
|
||||||
final IdentifiedUser i = (IdentifiedUser) getCurrentUser();
|
final IdentifiedUser i = (IdentifiedUser) getUser();
|
||||||
if (i.getAccountId().equals(reviewer)) {
|
if (i.getAccountId().equals(reviewer)) {
|
||||||
return true; // can remove self
|
return true; // can remove self
|
||||||
}
|
}
|
||||||
@@ -302,7 +302,7 @@ public class ChangeControl {
|
|||||||
if (getRefControl().canRemoveReviewer() // has removal permissions
|
if (getRefControl().canRemoveReviewer() // has removal permissions
|
||||||
|| getRefControl().isOwner() // branch owner
|
|| getRefControl().isOwner() // branch owner
|
||||||
|| getProjectControl().isOwner() // project owner
|
|| getProjectControl().isOwner() // project owner
|
||||||
|| getCurrentUser().getCapabilities().canAdministrateServer()) {
|
|| getUser().getCapabilities().canAdministrateServer()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,7 +316,7 @@ public class ChangeControl {
|
|||||||
return isOwner() // owner (aka creator) of the change can edit topic
|
return isOwner() // owner (aka creator) of the change can edit topic
|
||||||
|| getRefControl().isOwner() // branch owner can edit topic
|
|| getRefControl().isOwner() // branch owner can edit topic
|
||||||
|| getProjectControl().isOwner() // project owner can edit topic
|
|| getProjectControl().isOwner() // project owner can edit topic
|
||||||
|| getCurrentUser().getCapabilities().canAdministrateServer() // site administers are god
|
|| getUser().getCapabilities().canAdministrateServer() // site administers are god
|
||||||
|| getRefControl().canEditTopicName() // user can edit topic on a specific ref
|
|| getRefControl().canEditTopicName() // user can edit topic on a specific ref
|
||||||
;
|
;
|
||||||
} else {
|
} else {
|
||||||
@@ -329,7 +329,7 @@ public class ChangeControl {
|
|||||||
return isOwner() // owner (aka creator) of the change can edit hashtags
|
return isOwner() // owner (aka creator) of the change can edit hashtags
|
||||||
|| getRefControl().isOwner() // branch owner can edit hashtags
|
|| getRefControl().isOwner() // branch owner can edit hashtags
|
||||||
|| getProjectControl().isOwner() // project owner can edit hashtags
|
|| getProjectControl().isOwner() // project owner can edit hashtags
|
||||||
|| getCurrentUser().getCapabilities().canAdministrateServer() // site administers are god
|
|| getUser().getCapabilities().canAdministrateServer() // site administers are god
|
||||||
|| getRefControl().canEditHashtags(); // user can edit hashtag on a specific ref
|
|| getRefControl().canEditHashtags(); // user can edit hashtag on a specific ref
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,7 +343,7 @@ public class ChangeControl {
|
|||||||
|
|
||||||
private boolean match(String destBranch, String refPattern) {
|
private boolean match(String destBranch, String refPattern) {
|
||||||
return RefPatternMatcher.getMatcher(refPattern).match(destBranch,
|
return RefPatternMatcher.getMatcher(refPattern).match(destBranch,
|
||||||
getCurrentUser().getUserName());
|
getUser().getUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChangeData changeData(ReviewDb db, @Nullable ChangeData cd) {
|
private ChangeData changeData(ReviewDb db, @Nullable ChangeData cd) {
|
||||||
@@ -353,6 +353,6 @@ public class ChangeControl {
|
|||||||
public boolean isDraftVisible(ReviewDb db, ChangeData cd)
|
public boolean isDraftVisible(ReviewDb db, ChangeData cd)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
return isOwner() || isReviewer(db, cd) || getRefControl().canViewDrafts()
|
return isOwner() || isReviewer(db, cd) || getRefControl().canViewDrafts()
|
||||||
|| getCurrentUser().isInternalUser();
|
|| getUser().isInternalUser();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -138,7 +138,7 @@ public class ConfigInfo {
|
|||||||
actions = Maps.newTreeMap();
|
actions = Maps.newTreeMap();
|
||||||
for (UiAction.Description d : UiActions.from(
|
for (UiAction.Description d : UiActions.from(
|
||||||
views, new ProjectResource(control),
|
views, new ProjectResource(control),
|
||||||
Providers.of(control.getCurrentUser()))) {
|
Providers.of(control.getUser()))) {
|
||||||
actions.put(d.getId(), new ActionInfo(d));
|
actions.put(d.getId(), new ActionInfo(d));
|
||||||
}
|
}
|
||||||
this.theme = projectState.getTheme();
|
this.theme = projectState.getTheme();
|
||||||
|
@@ -100,7 +100,7 @@ class DashboardsCollection implements
|
|||||||
throw new ResourceNotFoundException(id);
|
throw new ResourceNotFoundException(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentUser user = myCtl.getCurrentUser();
|
CurrentUser user = myCtl.getUser();
|
||||||
String ref = parts.get(0);
|
String ref = parts.get(0);
|
||||||
String path = parts.get(1);
|
String path = parts.get(1);
|
||||||
for (ProjectState ps : myCtl.getProjectState().tree()) {
|
for (ProjectState ps : myCtl.getProjectState().tree()) {
|
||||||
|
@@ -90,7 +90,7 @@ class GetDashboard implements RestReadView<DashboardResource> {
|
|||||||
if ("default".equals(id)) {
|
if ("default".equals(id)) {
|
||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException();
|
||||||
} else if (!Strings.isNullOrEmpty(id)) {
|
} else if (!Strings.isNullOrEmpty(id)) {
|
||||||
ctl = ps.controlFor(ctl.getCurrentUser());
|
ctl = ps.controlFor(ctl.getUser());
|
||||||
return parse(ctl, id);
|
return parse(ctl, id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -185,7 +185,7 @@ public class ListBranches implements RestReadView<ProjectResource> {
|
|||||||
for (UiAction.Description d : UiActions.from(
|
for (UiAction.Description d : UiActions.from(
|
||||||
branchViews,
|
branchViews,
|
||||||
new BranchResource(refControl.getProjectControl(), info),
|
new BranchResource(refControl.getProjectControl(), info),
|
||||||
Providers.of(refControl.getCurrentUser()))) {
|
Providers.of(refControl.getUser()))) {
|
||||||
if (info.actions == null) {
|
if (info.actions == null) {
|
||||||
info.actions = new TreeMap<>();
|
info.actions = new TreeMap<>();
|
||||||
}
|
}
|
||||||
|
@@ -58,7 +58,7 @@ public class ListChildProjects implements RestReadView<ProjectResource> {
|
|||||||
public List<ProjectInfo> apply(ProjectResource rsrc) {
|
public List<ProjectInfo> apply(ProjectResource rsrc) {
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
return getChildProjectsRecursively(rsrc.getNameKey(),
|
return getChildProjectsRecursively(rsrc.getNameKey(),
|
||||||
rsrc.getControl().getCurrentUser());
|
rsrc.getControl().getUser());
|
||||||
} else {
|
} else {
|
||||||
return getDirectChildProjects(rsrc.getNameKey());
|
return getDirectChildProjects(rsrc.getNameKey());
|
||||||
}
|
}
|
||||||
|
@@ -64,7 +64,7 @@ class ListDashboards implements RestReadView<ProjectResource> {
|
|||||||
List<List<DashboardInfo>> all = Lists.newArrayList();
|
List<List<DashboardInfo>> all = Lists.newArrayList();
|
||||||
boolean setDefault = true;
|
boolean setDefault = true;
|
||||||
for (ProjectState ps : ctl.getProjectState().tree()) {
|
for (ProjectState ps : ctl.getProjectState().tree()) {
|
||||||
ctl = ps.controlFor(ctl.getCurrentUser());
|
ctl = ps.controlFor(ctl.getUser());
|
||||||
if (ctl.isVisible()) {
|
if (ctl.isVisible()) {
|
||||||
List<DashboardInfo> list = scan(ctl, project, setDefault);
|
List<DashboardInfo> list = scan(ctl, project, setDefault);
|
||||||
for (DashboardInfo d : list) {
|
for (DashboardInfo d : list) {
|
||||||
|
@@ -231,7 +231,7 @@ public class ProjectControl {
|
|||||||
return ctl;
|
return ctl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -67,7 +67,7 @@ public class PutDescription implements RestModifyView<ProjectResource, PutDescri
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProjectControl ctl = resource.getControl();
|
ProjectControl ctl = resource.getControl();
|
||||||
IdentifiedUser user = (IdentifiedUser) ctl.getCurrentUser();
|
IdentifiedUser user = (IdentifiedUser) ctl.getUser();
|
||||||
if (!ctl.isOwner()) {
|
if (!ctl.isOwner()) {
|
||||||
throw new AuthException("not project owner");
|
throw new AuthException("not project owner");
|
||||||
}
|
}
|
||||||
|
@@ -87,8 +87,8 @@ public class RefControl {
|
|||||||
return projectControl;
|
return projectControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
return projectControl.getCurrentUser();
|
return projectControl.getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RefControl forUser(CurrentUser who) {
|
public RefControl forUser(CurrentUser who) {
|
||||||
@@ -117,7 +117,7 @@ public class RefControl {
|
|||||||
public boolean isVisible() {
|
public boolean isVisible() {
|
||||||
if (isVisible == null) {
|
if (isVisible == null) {
|
||||||
isVisible =
|
isVisible =
|
||||||
(getCurrentUser().isInternalUser() || canPerform(Permission.READ))
|
(getUser().isInternalUser() || canPerform(Permission.READ))
|
||||||
&& canRead();
|
&& canRead();
|
||||||
}
|
}
|
||||||
return isVisible;
|
return isVisible;
|
||||||
@@ -206,7 +206,7 @@ public class RefControl {
|
|||||||
// this why for the AllProjects project we allow administrators to push
|
// this why for the AllProjects project we allow administrators to push
|
||||||
// configuration changes if they have push without being project owner.
|
// configuration changes if they have push without being project owner.
|
||||||
if (!(projectControl.getProjectState().isAllProjects() &&
|
if (!(projectControl.getProjectState().isAllProjects() &&
|
||||||
getCurrentUser().getCapabilities().canAdministrateServer())) {
|
getUser().getCapabilities().canAdministrateServer())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -257,12 +257,12 @@ public class RefControl {
|
|||||||
}
|
}
|
||||||
boolean owner;
|
boolean owner;
|
||||||
boolean admin;
|
boolean admin;
|
||||||
switch (getCurrentUser().getAccessPath()) {
|
switch (getUser().getAccessPath()) {
|
||||||
case REST_API:
|
case REST_API:
|
||||||
case JSON_RPC:
|
case JSON_RPC:
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
owner = isOwner();
|
owner = isOwner();
|
||||||
admin = getCurrentUser().getCapabilities().canAdministrateServer();
|
admin = getUser().getCapabilities().canAdministrateServer();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -302,8 +302,8 @@ public class RefControl {
|
|||||||
final PersonIdent tagger = tag.getTaggerIdent();
|
final PersonIdent tagger = tag.getTaggerIdent();
|
||||||
if (tagger != null) {
|
if (tagger != null) {
|
||||||
boolean valid;
|
boolean valid;
|
||||||
if (getCurrentUser().isIdentifiedUser()) {
|
if (getUser().isIdentifiedUser()) {
|
||||||
final IdentifiedUser user = (IdentifiedUser) getCurrentUser();
|
final IdentifiedUser user = (IdentifiedUser) getUser();
|
||||||
final String addr = tagger.getEmailAddress();
|
final String addr = tagger.getEmailAddress();
|
||||||
valid = user.hasEmailAddress(addr);
|
valid = user.hasEmailAddress(addr);
|
||||||
} else {
|
} else {
|
||||||
@@ -360,12 +360,12 @@ public class RefControl {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (getCurrentUser().getAccessPath()) {
|
switch (getUser().getAccessPath()) {
|
||||||
case GIT:
|
case GIT:
|
||||||
return canPushWithForce();
|
return canPushWithForce();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return getCurrentUser().getCapabilities().canAdministrateServer()
|
return getUser().getCapabilities().canAdministrateServer()
|
||||||
|| (isOwner() && !isForceBlocked(Permission.PUSH))
|
|| (isOwner() && !isForceBlocked(Permission.PUSH))
|
||||||
|| canPushWithForce();
|
|| canPushWithForce();
|
||||||
}
|
}
|
||||||
|
@@ -68,7 +68,7 @@ class SetDefaultDashboard implements RestModifyView<DashboardResource, Input> {
|
|||||||
input.id = Strings.emptyToNull(input.id);
|
input.id = Strings.emptyToNull(input.id);
|
||||||
|
|
||||||
ProjectControl ctl = resource.getControl();
|
ProjectControl ctl = resource.getControl();
|
||||||
IdentifiedUser user = (IdentifiedUser) ctl.getCurrentUser();
|
IdentifiedUser user = (IdentifiedUser) ctl.getUser();
|
||||||
if (!ctl.isOwner()) {
|
if (!ctl.isOwner()) {
|
||||||
throw new AuthException("not project owner");
|
throw new AuthException("not project owner");
|
||||||
}
|
}
|
||||||
|
@@ -71,7 +71,7 @@ public class SetParent implements RestModifyView<ProjectResource, Input> {
|
|||||||
ResourceNotFoundException, UnprocessableEntityException, IOException {
|
ResourceNotFoundException, UnprocessableEntityException, IOException {
|
||||||
ProjectControl ctl = rsrc.getControl();
|
ProjectControl ctl = rsrc.getControl();
|
||||||
validateParentUpdate(ctl, input.parent, checkIfAdmin);
|
validateParentUpdate(ctl, input.parent, checkIfAdmin);
|
||||||
IdentifiedUser user = (IdentifiedUser) ctl.getCurrentUser();
|
IdentifiedUser user = (IdentifiedUser) ctl.getUser();
|
||||||
try {
|
try {
|
||||||
MetaDataUpdate md = updateFactory.create(rsrc.getNameKey());
|
MetaDataUpdate md = updateFactory.create(rsrc.getNameKey());
|
||||||
try {
|
try {
|
||||||
@@ -109,7 +109,7 @@ public class SetParent implements RestModifyView<ProjectResource, Input> {
|
|||||||
public void validateParentUpdate(final ProjectControl ctl, String newParent,
|
public void validateParentUpdate(final ProjectControl ctl, String newParent,
|
||||||
boolean checkIfAdmin) throws AuthException, ResourceConflictException,
|
boolean checkIfAdmin) throws AuthException, ResourceConflictException,
|
||||||
UnprocessableEntityException {
|
UnprocessableEntityException {
|
||||||
IdentifiedUser user = (IdentifiedUser) ctl.getCurrentUser();
|
IdentifiedUser user = (IdentifiedUser) ctl.getUser();
|
||||||
if (checkIfAdmin && !user.getCapabilities().canAdministrateServer()) {
|
if (checkIfAdmin && !user.getCapabilities().canAdministrateServer()) {
|
||||||
throw new AuthException("not administrator");
|
throw new AuthException("not administrator");
|
||||||
}
|
}
|
||||||
|
@@ -220,7 +220,7 @@ public class SubmitRuleEvaluator {
|
|||||||
try {
|
try {
|
||||||
results = evaluateImpl("locate_submit_rule", "can_submit",
|
results = evaluateImpl("locate_submit_rule", "can_submit",
|
||||||
"locate_submit_filter", "filter_submit_results",
|
"locate_submit_filter", "filter_submit_results",
|
||||||
control.getCurrentUser());
|
control.getUser());
|
||||||
} catch (RuleEvalException e) {
|
} catch (RuleEvalException e) {
|
||||||
return ruleError(e.getMessage(), e);
|
return ruleError(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
@@ -544,7 +544,7 @@ public class ChangeData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cacheVisibleTo(ChangeControl ctl) {
|
void cacheVisibleTo(ChangeControl ctl) {
|
||||||
visibleTo = ctl.getCurrentUser();
|
visibleTo = ctl.getUser();
|
||||||
changeControl = ctl;
|
changeControl = ctl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -275,7 +275,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
|
|
||||||
IdentifiedUser getIdentifiedUser() throws QueryParseException {
|
IdentifiedUser getIdentifiedUser() throws QueryParseException {
|
||||||
try {
|
try {
|
||||||
CurrentUser u = getCurrentUser();
|
CurrentUser u = getUser();
|
||||||
if (u.isIdentifiedUser()) {
|
if (u.isIdentifiedUser()) {
|
||||||
return (IdentifiedUser) u;
|
return (IdentifiedUser) u;
|
||||||
}
|
}
|
||||||
@@ -285,7 +285,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CurrentUser getCurrentUser() throws QueryParseException {
|
CurrentUser getUser() throws QueryParseException {
|
||||||
try {
|
try {
|
||||||
return self.get();
|
return self.get();
|
||||||
} catch (ProvisionException e) {
|
} catch (ProvisionException e) {
|
||||||
@@ -679,7 +679,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Predicate<ChangeData> is_visible() throws QueryParseException {
|
public Predicate<ChangeData> is_visible() throws QueryParseException {
|
||||||
return visibleto(args.getCurrentUser());
|
return visibleto(args.getUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operator
|
@Operator
|
||||||
|
@@ -39,13 +39,13 @@ class IsWatchedByPredicate extends AndPredicate<ChangeData> {
|
|||||||
IsWatchedByPredicate(ChangeQueryBuilder.Arguments args,
|
IsWatchedByPredicate(ChangeQueryBuilder.Arguments args,
|
||||||
boolean checkIsVisible) throws QueryParseException {
|
boolean checkIsVisible) throws QueryParseException {
|
||||||
super(filters(args, checkIsVisible));
|
super(filters(args, checkIsVisible));
|
||||||
this.user = args.getCurrentUser();
|
this.user = args.getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Predicate<ChangeData>> filters(
|
private static List<Predicate<ChangeData>> filters(
|
||||||
ChangeQueryBuilder.Arguments args,
|
ChangeQueryBuilder.Arguments args,
|
||||||
boolean checkIsVisible) throws QueryParseException {
|
boolean checkIsVisible) throws QueryParseException {
|
||||||
CurrentUser user = args.getCurrentUser();
|
CurrentUser user = args.getUser();
|
||||||
List<Predicate<ChangeData>> r = Lists.newArrayList();
|
List<Predicate<ChangeData>> r = Lists.newArrayList();
|
||||||
ChangeQueryBuilder builder = new ChangeQueryBuilder(args);
|
ChangeQueryBuilder builder = new ChangeQueryBuilder(args);
|
||||||
for (AccountProjectWatch w : user.getNotificationFilters()) {
|
for (AccountProjectWatch w : user.getNotificationFilters()) {
|
||||||
|
@@ -37,7 +37,7 @@ public class FallbackRequestContext implements RequestContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@ public class ManualRequestContext implements RequestContext, AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@ public class PluginRequestContext implements RequestContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,6 +23,6 @@ import com.google.inject.Provider;
|
|||||||
* by the GerritGlobalModule scope.
|
* by the GerritGlobalModule scope.
|
||||||
*/
|
*/
|
||||||
public interface RequestContext {
|
public interface RequestContext {
|
||||||
CurrentUser getCurrentUser();
|
CurrentUser getUser();
|
||||||
Provider<ReviewDb> getReviewDbProvider();
|
Provider<ReviewDb> getReviewDbProvider();
|
||||||
}
|
}
|
||||||
|
@@ -188,8 +188,8 @@ public abstract class RequestScopePropagator {
|
|||||||
public T call() throws Exception {
|
public T call() throws Exception {
|
||||||
RequestContext old = local.setContext(new RequestContext() {
|
RequestContext old = local.setContext(new RequestContext() {
|
||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
return context.getCurrentUser();
|
return context.getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -31,7 +31,7 @@ public class ServerRequestContext implements RequestContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,7 +53,7 @@ public class ThreadLocalRequestContext {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
CurrentUser provideCurrentUser(RequestContext ctx) {
|
CurrentUser provideCurrentUser(RequestContext ctx) {
|
||||||
return ctx.getCurrentUser();
|
return ctx.getUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
@@ -204,7 +204,7 @@ public class CommentsTest {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
CurrentUser getCurrentUser(IdentifiedUser.GenericFactory userFactory) {
|
CurrentUser getUser(IdentifiedUser.GenericFactory userFactory) {
|
||||||
return userFactory.create(ownerId);
|
return userFactory.create(ownerId);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -166,7 +166,7 @@ public abstract class AbstractQueryChangesTest {
|
|||||||
userFactory.create(Providers.of(db), requestUserId);
|
userFactory.create(Providers.of(db), requestUserId);
|
||||||
return new RequestContext() {
|
return new RequestContext() {
|
||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
return requestUser;
|
return requestUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -104,7 +104,7 @@ public class TestChanges {
|
|||||||
IdentifiedUser user) throws OrmException {
|
IdentifiedUser user) throws OrmException {
|
||||||
ChangeControl ctl = EasyMock.createNiceMock(ChangeControl.class);
|
ChangeControl ctl = EasyMock.createNiceMock(ChangeControl.class);
|
||||||
expect(ctl.getChange()).andStubReturn(c);
|
expect(ctl.getChange()).andStubReturn(c);
|
||||||
expect(ctl.getCurrentUser()).andStubReturn(user);
|
expect(ctl.getUser()).andStubReturn(user);
|
||||||
ChangeNotes notes = new ChangeNotes(repoManager, migration, allUsers, c)
|
ChangeNotes notes = new ChangeNotes(repoManager, migration, allUsers, c)
|
||||||
.load();
|
.load();
|
||||||
expect(ctl.getNotes()).andStubReturn(notes);
|
expect(ctl.getNotes()).andStubReturn(notes);
|
||||||
|
@@ -99,7 +99,7 @@ class DatabasePubKeyAuth implements PublickeyAuthenticator {
|
|||||||
public boolean authenticate(String username, PublicKey suppliedKey,
|
public boolean authenticate(String username, PublicKey suppliedKey,
|
||||||
ServerSession session) {
|
ServerSession session) {
|
||||||
SshSession sd = session.getAttribute(SshSession.KEY);
|
SshSession sd = session.getAttribute(SshSession.KEY);
|
||||||
Preconditions.checkState(sd.getCurrentUser() == null);
|
Preconditions.checkState(sd.getUser() == null);
|
||||||
if (PeerDaemonUser.USER_NAME.equals(username)) {
|
if (PeerDaemonUser.USER_NAME.equals(username)) {
|
||||||
if (myHostKeys.contains(suppliedKey)
|
if (myHostKeys.contains(suppliedKey)
|
||||||
|| getPeerKeys().contains(suppliedKey)) {
|
|| getPeerKeys().contains(suppliedKey)) {
|
||||||
|
@@ -203,7 +203,7 @@ class SshLog implements LifecycleListener {
|
|||||||
|
|
||||||
private LoggingEvent log(final String msg) {
|
private LoggingEvent log(final String msg) {
|
||||||
final SshSession sd = session.get();
|
final SshSession sd = session.get();
|
||||||
final CurrentUser user = sd.getCurrentUser();
|
final CurrentUser user = sd.getUser();
|
||||||
|
|
||||||
final LoggingEvent event = new LoggingEvent( //
|
final LoggingEvent event = new LoggingEvent( //
|
||||||
Logger.class.getName(), // fqnOfCategoryClass
|
Logger.class.getName(), // fqnOfCategoryClass
|
||||||
@@ -261,7 +261,7 @@ class SshLog implements LifecycleListener {
|
|||||||
} else {
|
} else {
|
||||||
SshSession session = ctx.getSession();
|
SshSession session = ctx.getSession();
|
||||||
sessionId = IdGenerator.format(session.getSessionId());
|
sessionId = IdGenerator.format(session.getSessionId());
|
||||||
currentUser = session.getCurrentUser();
|
currentUser = session.getUser();
|
||||||
created = ctx.created;
|
created = ctx.created;
|
||||||
}
|
}
|
||||||
auditService.dispatch(new SshAuditEvent(sessionId, currentUser,
|
auditService.dispatch(new SshAuditEvent(sessionId, currentUser,
|
||||||
|
@@ -80,8 +80,8 @@ public class SshScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
final CurrentUser user = session.getCurrentUser();
|
final CurrentUser user = session.getUser();
|
||||||
if (user != null && user.isIdentifiedUser()) {
|
if (user != null && user.isIdentifiedUser()) {
|
||||||
IdentifiedUser identifiedUser = userFactory.create(((IdentifiedUser) user).getAccountId());
|
IdentifiedUser identifiedUser = userFactory.create(((IdentifiedUser) user).getAccountId());
|
||||||
identifiedUser.setAccessPath(user.getAccessPath());
|
identifiedUser.setAccessPath(user.getAccessPath());
|
||||||
|
@@ -60,7 +60,7 @@ public class SshSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Identity of the authenticated user account on the socket. */
|
/** Identity of the authenticated user account on the socket. */
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getUser() {
|
||||||
return identity;
|
return identity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -121,7 +121,7 @@ public class SshUtil {
|
|||||||
public static boolean success(final String username, final ServerSession session,
|
public static boolean success(final String username, final ServerSession session,
|
||||||
final SshScope sshScope, final SshLog sshLog,
|
final SshScope sshScope, final SshLog sshLog,
|
||||||
final SshSession sd, final CurrentUser user) {
|
final SshSession sd, final CurrentUser user) {
|
||||||
if (sd.getCurrentUser() == null) {
|
if (sd.getUser() == null) {
|
||||||
sd.authenticationSuccess(username, user);
|
sd.authenticationSuccess(username, user);
|
||||||
|
|
||||||
// If this is the first time we've authenticated this
|
// If this is the first time we've authenticated this
|
||||||
|
@@ -179,7 +179,7 @@ final class ShowConnections extends SshCommand {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
final CurrentUser user = sd.getCurrentUser();
|
final CurrentUser user = sd.getUser();
|
||||||
if (user != null && user.isIdentifiedUser()) {
|
if (user != null && user.isIdentifiedUser()) {
|
||||||
IdentifiedUser u = (IdentifiedUser) user;
|
IdentifiedUser u = (IdentifiedUser) user;
|
||||||
|
|
||||||
|
Submodule plugins/replication updated: efa3c6abaa...32e84b1b61
Reference in New Issue
Block a user