Replace pattern "user instanceof IdentifiedUser" with method call
Change-Id: Iac3af1340206ffd8f10db133bca5eab1f85926b6
This commit is contained in:
committed by
Shawn Pearce
parent
cd4be95d6e
commit
a35f8a20ab
@@ -256,7 +256,7 @@ 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() instanceof IdentifiedUser)) {
|
if (!(pc.getCurrentUser().isIdentifiedUser())) {
|
||||||
// Anonymous users are not permitted to push.
|
// Anonymous users are not permitted to push.
|
||||||
throw new ServiceNotAuthorizedException();
|
throw new ServiceNotAuthorizedException();
|
||||||
}
|
}
|
||||||
@@ -316,7 +316,7 @@ public class GitOverHttpServlet extends GitServlet {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(pc.getCurrentUser() instanceof IdentifiedUser)) {
|
if (!(pc.getCurrentUser().isIdentifiedUser())) {
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class RequireIdentifiedUserFilter implements Filter {
|
|||||||
public void doFilter(ServletRequest request,
|
public void doFilter(ServletRequest request,
|
||||||
ServletResponse response, FilterChain chain)
|
ServletResponse response, FilterChain chain)
|
||||||
throws IOException, ServletException {
|
throws IOException, ServletException {
|
||||||
if (user.get() instanceof IdentifiedUser) {
|
if (user.get().isIdentifiedUser()) {
|
||||||
chain.doFilter(request, response);
|
chain.doFilter(request, response);
|
||||||
} else {
|
} else {
|
||||||
HttpServletResponse res = (HttpServletResponse) response;
|
HttpServletResponse res = (HttpServletResponse) response;
|
||||||
|
|||||||
@@ -518,7 +518,7 @@ class GitWebServlet extends HttpServlet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String remoteUser = null;
|
String remoteUser = null;
|
||||||
if (project.getCurrentUser() instanceof IdentifiedUser) {
|
if (project.getCurrentUser().isIdentifiedUser()) {
|
||||||
final IdentifiedUser u = (IdentifiedUser) project.getCurrentUser();
|
final IdentifiedUser u = (IdentifiedUser) project.getCurrentUser();
|
||||||
final String user = u.getUserName();
|
final String user = u.getUserName();
|
||||||
env.set("GERRIT_USER_NAME", user);
|
env.set("GERRIT_USER_NAME", user);
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public class HostPageServlet extends HttpServlet {
|
|||||||
final Page.Content page = select(req);
|
final Page.Content page = select(req);
|
||||||
final StringWriter w = new StringWriter();
|
final StringWriter w = new StringWriter();
|
||||||
final CurrentUser user = currentUser.get();
|
final CurrentUser user = currentUser.get();
|
||||||
if (user instanceof IdentifiedUser) {
|
if (user.isIdentifiedUser()) {
|
||||||
w.write(HPD_ID + ".account=");
|
w.write(HPD_ID + ".account=");
|
||||||
json(((IdentifiedUser) user).getAccount(), w);
|
json(((IdentifiedUser) user).getAccount(), w);
|
||||||
w.write(";");
|
w.write(";");
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class BaseServiceImplementation {
|
|||||||
|
|
||||||
protected Account.Id getAccountId() {
|
protected Account.Id getAccountId() {
|
||||||
CurrentUser u = currentUser.get();
|
CurrentUser u = currentUser.get();
|
||||||
if (u instanceof IdentifiedUser) {
|
if (u.isIdentifiedUser()) {
|
||||||
return ((IdentifiedUser) u).getAccountId();
|
return ((IdentifiedUser) u).getAccountId();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ public class ChangeDetailFactory extends Handler<ChangeDetail> {
|
|||||||
Set<PatchSet.Id> patchesWithDraftComments = new HashSet<PatchSet.Id>();
|
Set<PatchSet.Id> patchesWithDraftComments = new HashSet<PatchSet.Id>();
|
||||||
final CurrentUser user = control.getCurrentUser();
|
final CurrentUser user = control.getCurrentUser();
|
||||||
final Account.Id me =
|
final Account.Id me =
|
||||||
user instanceof IdentifiedUser ? ((IdentifiedUser) user).getAccountId()
|
user.isIdentifiedUser() ? ((IdentifiedUser) user).getAccountId()
|
||||||
: null;
|
: null;
|
||||||
for (PatchSet ps : source) {
|
for (PatchSet ps : source) {
|
||||||
final PatchSet.Id psId = ps.getId();
|
final PatchSet.Id psId = ps.getId();
|
||||||
@@ -306,7 +306,7 @@ public class ChangeDetailFactory extends Handler<ChangeDetail> {
|
|||||||
|
|
||||||
final CurrentUser currentUser = control.getCurrentUser();
|
final CurrentUser currentUser = control.getCurrentUser();
|
||||||
Account.Id currentUserId = null;
|
Account.Id currentUserId = null;
|
||||||
if (currentUser instanceof IdentifiedUser) {
|
if (currentUser.isIdentifiedUser()) {
|
||||||
currentUserId = ((IdentifiedUser) currentUser).getAccountId();
|
currentUserId = ((IdentifiedUser) currentUser).getAccountId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ class PatchSetDetailFactory extends Handler<PatchSetDetail> {
|
|||||||
detail.setPatches(patches);
|
detail.setPatches(patches);
|
||||||
|
|
||||||
final CurrentUser user = control.getCurrentUser();
|
final CurrentUser user = control.getCurrentUser();
|
||||||
if (user instanceof IdentifiedUser) {
|
if (user.isIdentifiedUser()) {
|
||||||
// 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
|
||||||
// quickly locate where they have pending drafts, and review them.
|
// quickly locate where they have pending drafts, and review them.
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ class HttpLog extends AbstractLifeCycle implements RequestLog {
|
|||||||
uri = uri + "?" + qs;
|
uri = uri + "?" + qs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user instanceof IdentifiedUser) {
|
if (user.isIdentifiedUser()) {
|
||||||
IdentifiedUser who = (IdentifiedUser) user;
|
IdentifiedUser who = (IdentifiedUser) user;
|
||||||
if (who.getUserName() != null && !who.getUserName().isEmpty()) {
|
if (who.getUserName() != null && !who.getUserName().isEmpty()) {
|
||||||
event.setProperty(P_USER, who.getUserName());
|
event.setProperty(P_USER, who.getUserName());
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ public class ProjectQoSFilter implements Filter {
|
|||||||
String userName = "";
|
String userName = "";
|
||||||
|
|
||||||
CurrentUser who = userProvider.get();
|
CurrentUser who = userProvider.get();
|
||||||
if (who instanceof IdentifiedUser) {
|
if (who.isIdentifiedUser()) {
|
||||||
String name = ((IdentifiedUser) who).getUserName();
|
String name = ((IdentifiedUser) who).getUserName();
|
||||||
if (name != null && !name.isEmpty()) {
|
if (name != null && !name.isEmpty()) {
|
||||||
userName = " (" + name + ")";
|
userName = " (" + name + ")";
|
||||||
|
|||||||
@@ -95,4 +95,9 @@ public abstract class CurrentUser {
|
|||||||
}
|
}
|
||||||
return capabilities;
|
return capabilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Check if user is the IdentifiedUser */
|
||||||
|
public boolean isIdentifiedUser() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -412,4 +412,10 @@ public class IdentifiedUser extends CurrentUser {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "IdentifiedUser[account " + getAccountId() + "]";
|
return "IdentifiedUser[account " + getAccountId() + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Check if user is the IdentifiedUser */
|
||||||
|
@Override
|
||||||
|
public boolean isIdentifiedUser() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ public class AccountControl {
|
|||||||
*/
|
*/
|
||||||
public boolean canSee(final Account.Id otherUser) {
|
public boolean canSee(final Account.Id otherUser) {
|
||||||
// Special case: I can always see myself.
|
// Special case: I can always see myself.
|
||||||
if (currentUser instanceof IdentifiedUser
|
if (currentUser.isIdentifiedUser()
|
||||||
&& ((IdentifiedUser) currentUser).getAccountId().equals(otherUser)) {
|
&& ((IdentifiedUser) currentUser).getAccountId().equals(otherUser)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ public class AccountsCollection implements
|
|||||||
CurrentUser user = self.get();
|
CurrentUser user = self.get();
|
||||||
|
|
||||||
if (id.equals("self")) {
|
if (id.equals("self")) {
|
||||||
if (user instanceof IdentifiedUser) {
|
if (user.isIdentifiedUser()) {
|
||||||
return (IdentifiedUser) user;
|
return (IdentifiedUser) user;
|
||||||
} else if (user instanceof AnonymousUser) {
|
} else if (user instanceof AnonymousUser) {
|
||||||
throw new AuthException("Authentication required");
|
throw new AuthException("Authentication required");
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ public class GroupControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canSeeMember(Account.Id id) {
|
public boolean canSeeMember(Account.Id id) {
|
||||||
if (user instanceof IdentifiedUser
|
if (user.isIdentifiedUser()
|
||||||
&& ((IdentifiedUser) user).getAccountId().equals(id)) {
|
&& ((IdentifiedUser) user).getAccountId().equals(id)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ public class LdapGroupBackend implements GroupBackend {
|
|||||||
|
|
||||||
String groupDn = uuid.get().substring(LDAP_UUID.length());
|
String groupDn = uuid.get().substring(LDAP_UUID.length());
|
||||||
CurrentUser user = userProvider.get();
|
CurrentUser user = userProvider.get();
|
||||||
if (!(user instanceof IdentifiedUser)
|
if (!(user.isIdentifiedUser())
|
||||||
|| !membershipsOf((IdentifiedUser) user).contains(uuid)) {
|
|| !membershipsOf((IdentifiedUser) user).contains(uuid)) {
|
||||||
try {
|
try {
|
||||||
if (!existsCache.get(groupDn)) {
|
if (!existsCache.get(groupDn)) {
|
||||||
|
|||||||
@@ -289,7 +289,7 @@ public class ChangeJson {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (has(CURRENT_ACTIONS) && userProvider.get() instanceof IdentifiedUser) {
|
if (has(CURRENT_ACTIONS) && userProvider.get().isIdentifiedUser()) {
|
||||||
out.actions = Maps.newTreeMap();
|
out.actions = Maps.newTreeMap();
|
||||||
for (UiAction.Description d : UiActions.from(
|
for (UiAction.Description d : UiActions.from(
|
||||||
changes,
|
changes,
|
||||||
@@ -698,7 +698,7 @@ public class ChangeJson {
|
|||||||
|
|
||||||
private boolean isChangeReviewed(ChangeData cd) throws OrmException {
|
private boolean isChangeReviewed(ChangeData cd) throws OrmException {
|
||||||
CurrentUser user = userProvider.get();
|
CurrentUser user = userProvider.get();
|
||||||
if (user instanceof IdentifiedUser) {
|
if (user.isIdentifiedUser()) {
|
||||||
PatchSet currentPatchSet = cd.currentPatchSet(db);
|
PatchSet currentPatchSet = cd.currentPatchSet(db);
|
||||||
if (currentPatchSet == null) {
|
if (currentPatchSet == null) {
|
||||||
return false;
|
return false;
|
||||||
@@ -779,7 +779,7 @@ public class ChangeJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (out.isCurrent && has(CURRENT_ACTIONS)
|
if (out.isCurrent && has(CURRENT_ACTIONS)
|
||||||
&& userProvider.get() instanceof IdentifiedUser) {
|
&& userProvider.get().isIdentifiedUser()) {
|
||||||
out.actions = Maps.newTreeMap();
|
out.actions = Maps.newTreeMap();
|
||||||
for (UiAction.Description d : UiActions.from(
|
for (UiAction.Description d : UiActions.from(
|
||||||
revisions,
|
revisions,
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class ChangeResource implements RestResource, HasETag {
|
|||||||
Hasher h = Hashing.md5().newHasher()
|
Hasher h = Hashing.md5().newHasher()
|
||||||
.putLong(getChange().getLastUpdatedOn().getTime())
|
.putLong(getChange().getLastUpdatedOn().getTime())
|
||||||
.putInt(getChange().getRowVersion())
|
.putInt(getChange().getRowVersion())
|
||||||
.putInt(user instanceof IdentifiedUser
|
.putInt(user.isIdentifiedUser()
|
||||||
? ((IdentifiedUser) user).getAccountId().get()
|
? ((IdentifiedUser) user).getAccountId().get()
|
||||||
: 0);
|
: 0);
|
||||||
|
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ class Drafts implements ChildCollection<RevisionResource, DraftResource> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkIdentifiedUser() throws AuthException {
|
private void checkIdentifiedUser() throws AuthException {
|
||||||
if (!(user.get() instanceof IdentifiedUser)) {
|
if (!(user.get().isIdentifiedUser())) {
|
||||||
throw new AuthException("drafts only available to authenticated users");
|
throw new AuthException("drafts only available to authenticated users");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ class Files implements ChildCollection<RevisionResource, FileResource> {
|
|||||||
private Object reviewed(RevisionResource resource)
|
private Object reviewed(RevisionResource resource)
|
||||||
throws AuthException, OrmException {
|
throws AuthException, OrmException {
|
||||||
CurrentUser user = self.get();
|
CurrentUser user = self.get();
|
||||||
if (!(user instanceof IdentifiedUser)) {
|
if (!(user.isIdentifiedUser())) {
|
||||||
throw new AuthException("Authentication required");
|
throw new AuthException("Authentication required");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class GroupsCollection implements
|
|||||||
final CurrentUser user = self.get();
|
final CurrentUser user = self.get();
|
||||||
if (user instanceof AnonymousUser) {
|
if (user instanceof AnonymousUser) {
|
||||||
throw new AuthException("Authentication required");
|
throw new AuthException("Authentication required");
|
||||||
} else if(!(user instanceof IdentifiedUser)) {
|
} else if(!(user.isIdentifiedUser())) {
|
||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ public class GroupsCollection implements
|
|||||||
final CurrentUser user = self.get();
|
final CurrentUser user = self.get();
|
||||||
if (user instanceof AnonymousUser) {
|
if (user instanceof AnonymousUser) {
|
||||||
throw new AuthException("Authentication required");
|
throw new AuthException("Authentication required");
|
||||||
} else if(!(user instanceof IdentifiedUser)) {
|
} else if(!(user.isIdentifiedUser())) {
|
||||||
throw new ResourceNotFoundException(id);
|
throw new ResourceNotFoundException(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ public class PatchScriptFactory implements Callable<PatchScript> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final CurrentUser user = control.getCurrentUser();
|
final CurrentUser user = control.getCurrentUser();
|
||||||
if (user instanceof IdentifiedUser) {
|
if (user.isIdentifiedUser()) {
|
||||||
final Account.Id me = ((IdentifiedUser) user).getAccountId();
|
final Account.Id me = ((IdentifiedUser) user).getAccountId();
|
||||||
switch (changeType) {
|
switch (changeType) {
|
||||||
case ADDED:
|
case ADDED:
|
||||||
|
|||||||
@@ -264,7 +264,7 @@ 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() instanceof IdentifiedUser) {
|
if (getCurrentUser().isIdentifiedUser()) {
|
||||||
final IdentifiedUser i = (IdentifiedUser) getCurrentUser();
|
final IdentifiedUser i = (IdentifiedUser) getCurrentUser();
|
||||||
return i.getAccountId().equals(change.getOwner());
|
return i.getAccountId().equals(change.getOwner());
|
||||||
}
|
}
|
||||||
@@ -279,7 +279,7 @@ 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() instanceof IdentifiedUser) {
|
if (getCurrentUser().isIdentifiedUser()) {
|
||||||
final IdentifiedUser user = (IdentifiedUser) getCurrentUser();
|
final IdentifiedUser user = (IdentifiedUser) getCurrentUser();
|
||||||
Iterable<PatchSetApproval> results;
|
Iterable<PatchSetApproval> results;
|
||||||
if (cd != null) {
|
if (cd != null) {
|
||||||
@@ -305,7 +305,7 @@ 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() instanceof IdentifiedUser) {
|
if (getCurrentUser().isIdentifiedUser()) {
|
||||||
final IdentifiedUser i = (IdentifiedUser) getCurrentUser();
|
final IdentifiedUser i = (IdentifiedUser) getCurrentUser();
|
||||||
if (i.getAccountId().equals(reviewer)) {
|
if (i.getAccountId().equals(reviewer)) {
|
||||||
return true; // can remove self
|
return true; // can remove self
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ public class ProjectControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Capable verifyActiveContributorAgreement() {
|
private Capable verifyActiveContributorAgreement() {
|
||||||
if (! (user instanceof IdentifiedUser)) {
|
if (! (user.isIdentifiedUser())) {
|
||||||
return new Capable("Must be logged in to verify Contributor Agreement");
|
return new Capable("Must be logged in to verify Contributor Agreement");
|
||||||
}
|
}
|
||||||
final IdentifiedUser iUser = (IdentifiedUser) user;
|
final IdentifiedUser iUser = (IdentifiedUser) user;
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ 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() instanceof IdentifiedUser) {
|
if (getCurrentUser().isIdentifiedUser()) {
|
||||||
final IdentifiedUser user = (IdentifiedUser) getCurrentUser();
|
final IdentifiedUser user = (IdentifiedUser) getCurrentUser();
|
||||||
final String addr = tagger.getEmailAddress();
|
final String addr = tagger.getEmailAddress();
|
||||||
valid = user.getEmailAddresses().contains(addr);
|
valid = user.getEmailAddresses().contains(addr);
|
||||||
|
|||||||
@@ -437,7 +437,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
Set<Account.Id> m = parseAccount(who);
|
Set<Account.Id> m = parseAccount(who);
|
||||||
List<IsWatchedByPredicate> p = Lists.newArrayListWithCapacity(m.size());
|
List<IsWatchedByPredicate> p = Lists.newArrayListWithCapacity(m.size());
|
||||||
for (Account.Id id : m) {
|
for (Account.Id id : m) {
|
||||||
if (currentUser instanceof IdentifiedUser
|
if (currentUser.isIdentifiedUser()
|
||||||
&& id.equals(((IdentifiedUser) currentUser).getAccountId())) {
|
&& id.equals(((IdentifiedUser) currentUser).getAccountId())) {
|
||||||
p.add(new IsWatchedByPredicate(args, currentUser, false));
|
p.add(new IsWatchedByPredicate(args, currentUser, false));
|
||||||
} else {
|
} else {
|
||||||
@@ -656,7 +656,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Account.Id self() {
|
private Account.Id self() {
|
||||||
if (currentUser instanceof IdentifiedUser) {
|
if (currentUser.isIdentifiedUser()) {
|
||||||
return ((IdentifiedUser) currentUser).getAccountId();
|
return ((IdentifiedUser) currentUser).getAccountId();
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import java.util.Set;
|
|||||||
class IsStarredByPredicate extends OrPredicate<ChangeData> implements
|
class IsStarredByPredicate extends OrPredicate<ChangeData> implements
|
||||||
ChangeDataSource {
|
ChangeDataSource {
|
||||||
private static String describe(CurrentUser user) {
|
private static String describe(CurrentUser user) {
|
||||||
if (user instanceof IdentifiedUser) {
|
if (user.isIdentifiedUser()) {
|
||||||
return ((IdentifiedUser) user).getAccountId().toString();
|
return ((IdentifiedUser) user).getAccountId().toString();
|
||||||
}
|
}
|
||||||
return user.toString();
|
return user.toString();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import com.google.inject.Provider;
|
|||||||
|
|
||||||
class IsVisibleToPredicate extends OperatorPredicate<ChangeData> {
|
class IsVisibleToPredicate extends OperatorPredicate<ChangeData> {
|
||||||
private static String describe(CurrentUser user) {
|
private static String describe(CurrentUser user) {
|
||||||
if (user instanceof IdentifiedUser) {
|
if (user.isIdentifiedUser()) {
|
||||||
return ((IdentifiedUser) user).getAccountId().toString();
|
return ((IdentifiedUser) user).getAccountId().toString();
|
||||||
}
|
}
|
||||||
if (user instanceof SingleGroupUser) {
|
if (user instanceof SingleGroupUser) {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import java.util.List;
|
|||||||
|
|
||||||
class IsWatchedByPredicate extends AndPredicate<ChangeData> {
|
class IsWatchedByPredicate extends AndPredicate<ChangeData> {
|
||||||
private static String describe(CurrentUser user) {
|
private static String describe(CurrentUser user) {
|
||||||
if (user instanceof IdentifiedUser) {
|
if (user.isIdentifiedUser()) {
|
||||||
return ((IdentifiedUser) user).getAccountId().toString();
|
return ((IdentifiedUser) user).getAccountId().toString();
|
||||||
}
|
}
|
||||||
return user.toString();
|
return user.toString();
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class ThreadLocalRequestContext {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
IdentifiedUser provideCurrentUser(CurrentUser user) {
|
IdentifiedUser provideCurrentUser(CurrentUser user) {
|
||||||
if (user instanceof IdentifiedUser) {
|
if (user.isIdentifiedUser()) {
|
||||||
return (IdentifiedUser) user;
|
return (IdentifiedUser) user;
|
||||||
}
|
}
|
||||||
throw new ProvisionException(NotSignedInException.MESSAGE,
|
throw new ProvisionException(NotSignedInException.MESSAGE,
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class PRED_current_user_1 extends Predicate.P1 {
|
|||||||
CurrentUser curUser = cControl.getCurrentUser();
|
CurrentUser curUser = cControl.getCurrentUser();
|
||||||
Term resultTerm;
|
Term resultTerm;
|
||||||
|
|
||||||
if (curUser instanceof IdentifiedUser) {
|
if (curUser.isIdentifiedUser()) {
|
||||||
Account.Id id = ((IdentifiedUser)curUser).getAccountId();
|
Account.Id id = ((IdentifiedUser)curUser).getAccountId();
|
||||||
resultTerm = new IntegerTerm(id.get());
|
resultTerm = new IntegerTerm(id.get());
|
||||||
} else if (curUser instanceof AnonymousUser) {
|
} else if (curUser instanceof AnonymousUser) {
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ public abstract class BaseCommand implements Command {
|
|||||||
} else {
|
} else {
|
||||||
final StringBuilder m = new StringBuilder();
|
final StringBuilder m = new StringBuilder();
|
||||||
m.append("Internal server error");
|
m.append("Internal server error");
|
||||||
if (userProvider.get() instanceof IdentifiedUser) {
|
if (userProvider.get().isIdentifiedUser()) {
|
||||||
final IdentifiedUser u = (IdentifiedUser) userProvider.get();
|
final IdentifiedUser u = (IdentifiedUser) userProvider.get();
|
||||||
m.append(" (user ");
|
m.append(" (user ");
|
||||||
m.append(u.getAccount().getUserName());
|
m.append(u.getAccount().getUserName());
|
||||||
@@ -403,7 +403,7 @@ public abstract class BaseCommand implements Command {
|
|||||||
|
|
||||||
StringBuilder m = new StringBuilder();
|
StringBuilder m = new StringBuilder();
|
||||||
m.append(context.getCommandLine());
|
m.append(context.getCommandLine());
|
||||||
if (userProvider.get() instanceof IdentifiedUser) {
|
if (userProvider.get().isIdentifiedUser()) {
|
||||||
IdentifiedUser u = (IdentifiedUser) userProvider.get();
|
IdentifiedUser u = (IdentifiedUser) userProvider.get();
|
||||||
m.append(" (" + u.getAccount().getUserName() + ")");
|
m.append(" (" + u.getAccount().getUserName() + ")");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ class SshLog implements LifecycleListener {
|
|||||||
|
|
||||||
String userName = "-", accountId = "-";
|
String userName = "-", accountId = "-";
|
||||||
|
|
||||||
if (user instanceof IdentifiedUser) {
|
if (user.isIdentifiedUser()) {
|
||||||
IdentifiedUser u = (IdentifiedUser) user;
|
IdentifiedUser u = (IdentifiedUser) user;
|
||||||
userName = u.getAccount().getUserName();
|
userName = u.getAccount().getUserName();
|
||||||
accountId = "a/" + u.getAccountId().toString();
|
accountId = "a/" + u.getAccountId().toString();
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class SshScope {
|
|||||||
@Override
|
@Override
|
||||||
public CurrentUser getCurrentUser() {
|
public CurrentUser getCurrentUser() {
|
||||||
final CurrentUser user = session.getCurrentUser();
|
final CurrentUser user = session.getCurrentUser();
|
||||||
if (user instanceof IdentifiedUser) {
|
if (user.isIdentifiedUser()) {
|
||||||
IdentifiedUser identifiedUser = userFactory.create(((IdentifiedUser) user).getAccountId());
|
IdentifiedUser identifiedUser = userFactory.create(((IdentifiedUser) user).getAccountId());
|
||||||
identifiedUser.setAccessPath(user.getAccessPath());
|
identifiedUser.setAccessPath(user.getAccessPath());
|
||||||
return identifiedUser;
|
return identifiedUser;
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ final class ShowConnections extends SshCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final CurrentUser user = sd.getCurrentUser();
|
final CurrentUser user = sd.getCurrentUser();
|
||||||
if (user instanceof IdentifiedUser) {
|
if (user.isIdentifiedUser()) {
|
||||||
IdentifiedUser u = (IdentifiedUser) user;
|
IdentifiedUser u = (IdentifiedUser) user;
|
||||||
|
|
||||||
if (!numeric) {
|
if (!numeric) {
|
||||||
|
|||||||
Reference in New Issue
Block a user