As done with the GET and HEAD methods, extract to individual methods
checking if a request is of type DELETE, POST or PUT.
Change-Id: If159ea2aaaac32ac6747b1242cefbb6532dc63bc
Returning Optional makes it more explicit that callers must expect that
the return value is absent.
Change-Id: If739844482ac8966dbcdc2285869cfac7ab7e059
Signed-off-by: Edwin Kempin <ekempin@google.com>
* changes:
Rename DbGroupMemberAuditListener to DbGroupAuditListener
Send group audit events also when completely on NoteDb
Redefine interface for group audit listeners
Using "Patch Set N was rebased" misleads the reader into thinking the
kind is TRIVIAL_REBASE, even though this message was previously used for
other types as well.
Change-Id: If4526c6ffae7d45b3ae16df9dc90bb4245906598
Many REST API endpoints require an internal group and return 405 if the
group is not an internal group. This is a non-obvious requirement and
contract of API, so make it explicit in the documentation.
Provide a more descriptive message in the error text, and add a new
subclass NotInternalGroupException to avoid the need to repeat ourselves
in each endpoint handler.
Change-Id: I993ebf98ce4eb565b9f98ff10742114d57ce6f9a
This class is no longer a ReviewDb class and hence these annotations are
no longer needed.
We cannot remove the @Column annotation from Account.Id. This because we
store a proto for changes in the change index which includes an account
ID and protobuf needs this annotation for encoding/decoding.
Change-Id: Id3ad4a3454b1fc84527bd3a578b9f8db85883cf8
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit migrates the existing group audit listener from
the old GroupMemberAuditListener to the new GroupAuditListener
interface.
Before this commit, group audit events are dispatched only
for ReviewDb updates. After this, they will be dispatched for
both ReviewDb and NoteDb updates.
To make DbGroupMemberAuditListener easier for review, this commit
doesn't rename it. In the child change, it's renamed to
DbGroupAuditListener.
Change-Id: Ie9ad8ec3af0fb298556de677dcfcc0bf9f479a6c
Gerrit slaves are read-only and hence pushing to them is disabled.
Pushes over SSH come in as git-receive-pack commands. For slaves this
command is mapped to an SSH Command class that fails immediately so that
pushes on slaves are disabled. This SSH Command class is also supposed
to provide a meaningful error message to the client (see change
Ia25012486b). However this didn't work:
1. A git-receive-pack command has the project name to which the push is
done as argument:
The SSH Command class that was bound for git-receive-pack commands on
slaves didn't allow any argument. Hence the request already failed
during the command parsing so that the bound SSH Command class was
not executed.
2. When using JGit on client-side the exception message from the server
didn't reach the client. On client side the error was always "Short
read of block". Then the client checked whether the remote repository
exists by fetching from it. For slaves this fetch works and then JGit
returned "push not permitted" as error message to the callers.
To fix 1 the SSH Command class that is bound for git-receive-pack
commands on slaves now extends AbstractGitCommand which defines the
argument for the project name.
To fix 2 we write out a special ERR packet which allows to pass a
customized remote service error to the client.
The error message that we return from slaves when pushing is now
consistent between SSH and HTTP. In both cases we now throw a
ServiceNotEnabledException.
Change-Id: Id99e93d0127d58114b54b4deea7f5227b920c8e2
Signed-off-by: Edwin Kempin <ekempin@google.com>
* stable-2.15:
Reset state flags on loadData calls
ReceiveCommits: Fix NEW_PATCHSET regex pattern
CreateChangeIT#createNewChangeSignedOffByFooter: Remove unnecessary assume
CommitValidators: Always check for Change-Id in subject line
AbstractPushForReview: Factor repeated code to setRequireChangeId method
Bazel: Use rules_closure from HEAD
Change-Id: Ifb35377d72c3f4bd085944f16a6a1264ecad2141
This class is no longer a ReviewDb class and shouldn't be used by the GWT UI.
Change-Id: I46b1b76c2375700ecaac5bc547e7507b11869d64
Signed-off-by: Edwin Kempin <ekempin@google.com>
The default constructor was needed for instantiated this class in the
GWT UI, but the GWT UI is no longer using this class.
Change-Id: I6ad28e50d2d617eb91fcff927ea77ac788d61833
Signed-off-by: Edwin Kempin <ekempin@google.com>
* changes:
AccountSshKey: Remove dependency to gwtorm
Don't use Account class in GWT UI code
Move regular expressions for user name from Account to ExternalId
Account.Id: Return Optional from parse method
ChangeField: Ignore invalid reviewer field values and log an error
ChangeData: Expect that Account.Id.fromRefPart may return null
AccountResolver: Inside of map methods use the id from the provided account
We have migrated groups to NoteDb. But we didn't send audit events
to group audit listeners for NoteDb group updates. That means
existing listeners are broken. Instead of sending out NoteDb events
directly to fix them, we could take the chance to redefine a better
interface for those listeners. By doing this, we hope we don't need
to break them multiple times in the future.
This commit defines GroupAuditEvent interface which is implemented
by two group audit event, i.e. GroupMembersAuditEvent and
GroupSubgroupsAuditEvent. Hopefully, there will be
GroupRenameAuditEvent when we support renaming a group.
The follow-up commit will delete the old GroupMemberAuditLisenter
interface and migrate existing usages to the new interface.
Change-Id: I6d7d97e9cf5e4aae148d28e706b331163cf74d3e
This class is no longer a ReviewDb class and should be moved out of the
reviewdb.client package. For this we must not depend on gwtorm classes
like IntKey.
Change-Id: I30181547b7ddf3d9d9cab53bdd12c4b9bb792ed5
Signed-off-by: Edwin Kempin <ekempin@google.com>
User names are stored as external IDs, hence the regular expressions to
validate the format of a user name should be part of the ExternalId
class.
There is one place in the GWT UI where user names are validated. Since
the GWT UI doesn't have access to the ExternalId class it needs to copy
two of the regular expressions. This should be OK since the format of
user names is not expected to change and the GWT UI will be gone soon.
It's actually a goal to remove all dependencies from the GWT UI on the
Account class so that the Account class can be moved out of the
reviewdb.client package and be turned into an immutable AutoValue type.
Change-Id: I6ea7139019eb0e7f0e06efaf77ec4bd89d514006
Signed-off-by: Edwin Kempin <ekempin@google.com>
Similar to change refs, cache-automerge refs are not tag-able since
they are simply used for Gerrit-internal data representation. Excluding
them from the list of interesting refs in TagSet scales down on the
amount of work we have to do later on when calculating tags.
The fewer references we have prior to calculating the tags, the less
memory we'll need when using BitSets to deal with refs flags.
Change-Id: I25b301bba5f22e94c6339a6bf2e3b87a505202f3
This is better than throwing a NumberFormatException as done before.
Callers can easily forget to handle NumberFormatException. It's better
to return an Optional so that it's obvious that callers must handle the
case where parsing didn't succeed.
Change-Id: I0bade70a31430674c739f7e1af51f71f22027c88
Signed-off-by: Edwin Kempin <ekempin@google.com>
We didn't see any failures with this, but it's better to be able to
handle invalid data from the index.
Change-Id: I958ec9851337d9f76349e81c04ee2358a738dde5
Signed-off-by: Edwin Kempin <ekempin@google.com>
In practice this should never happen since before calling
Account.Id.fromRefPart we verified that it's a change edit ref. Hence
this is not a bug-fix but rather improving readability.
We cannot annotate Account.Id.fromRefPart with @Nullable since the
Account class is used in the GWT UI where @Nullable is not available.
However the follow-up change modifies this method to return an Optional.
Change-Id: Iae9d34e4ee225decd6ab4367827c1505d18acbdb
Signed-off-by: Edwin Kempin <ekempin@google.com>
This should be always the same ID as 'id' but like this it's more
readable.
Change-Id: Ie7eed61baad09510ce98395ca1f5c672f08ea2b3
Signed-off-by: Edwin Kempin <ekempin@google.com>
Similar to normal change refs, meta refs are not tag-able. Excluding
them from the list of interesting refs in TagSet scales down on the
amount of work we have to do later on when calculating tags.
The fewer references we have prior to calculating the tags, the less
memory we'll need when using BitSets to deal with refs flags.
Change-Id: Idc3308e3378bfede57d95cd65457129484385794
This method is used only tests and in isOwner().
In isOwner, use the stronger canPerform() method.
Blocking a user is not a observable part of the permission system, so
it should not be tested. To check that a user is blocked, one should
grant permissions in a child project, and observe that the child
permission is ignored.
Change-Id: I66fb450901eec2169883724c55445fab8e5f7bfa
maybeGet is the method that most callers should use. Make this more
obvious by renaming it to get. Also the return type of Optional already
implies that there might not be a result, hence the method name doesn't
need to be explicit about this.
Change-Id: I571fa9989b2629d96f2238d4b8571d669a9bc89d
Signed-off-by: Edwin Kempin <ekempin@google.com>
AccountCache#get returns an empty AccountState to represent a missing
account, but most callers are not aware of this. Make this behavior
obvious by having an explicit name.
Most callers of AccountCache should use maybeGet and handle the missing
account case explicitly. A follow-up change can now rename maybeGet to
get to make it more obvious that this is the method that should be used
by default.
Within this series quite some callers of AccountCache#get have been
migrated to AccountCache#maybeGet. The remaining usages of
AccountCache#get (now AccountCache#getEvenIfMissing) cannot easily be
migrated to AccountCache#maybeGet, at least not without changing
behavior. Ideally we still want to migrate all callers to
AccountCache#maybeGet and then get rid of AccountCache#get (now
AccountCache#getEvenIfMissing), but this work is left for future
changes.
Change-Id: Ib993cb5ce9498ed52032ce9f7be0d314456ff20d
Signed-off-by: Edwin Kempin <ekempin@google.com>
AccountCache#get returns an empty AccountState to represent a missing
account. Handle the missing account case explicitly instead of using an
empty AccountState.
Change-Id: I67a9309007c9946af8407258045aea11a49336ed
Signed-off-by: Edwin Kempin <ekempin@google.com>
* changes:
ChangeNoteUtil: Support PersonIdent creation by account ID
FromAddressGeneratorProvider: Use AccountCache#maybeGet instead of AccountCache#get
* changes:
DbGroupMemberAuditListener: Use AccountCache#maybeGet instead of AccountCache#get
AccountResolver: Use AccountCache#maybeGet instead of AccountCache#get
ChangeResource: Use AccountCache#maybeGet instead of AccountCache#get
SetMembersCommand: Use AccountCache#maybeGet instead of AccountCache#get
Change Ia1fcdb3c9b made the getUserName() method return an Optional
and callers rely on this method to never return null. However when the
setUserName method was not invoked userName was still null. This
resulted in a NullPointerException when trying to create a new account
from the "New Account" button on the login page when using
DEVELOPMENT_BECOME_ANY_ACCOUNT [1]. Fix this by initializing userName
with Optional.empty().
[1]
com.google.gerrit.pgm.http.jetty.HiddenErrorHandler : Error in POST /login
java.lang.NullPointerException
at com.google.gerrit.server.account.AccountManager.create(AccountManager.java:285)
at com.google.gerrit.server.account.AccountManager.authenticate(AccountManager.java:147)
at com.google.gerrit.httpd.auth.become.BecomeAnyAccountLoginServlet.create(BecomeAnyAccountLoginServlet.java:248)
at com.google.gerrit.httpd.auth.become.BecomeAnyAccountLoginServlet.doPost(BecomeAnyAccountLoginServlet.java:100)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
...
Change-Id: Ied5d6ec93e7e5d1b1f72106e2f28d0cd1c224c08
Signed-off-by: Edwin Kempin <ekempin@google.com>