Class CreateEmail
- All Implemented Interfaces:
RestCollectionCreateView<AccountResource,
,AccountResource.Email, EmailInput> RestCollectionView<AccountResource,
,AccountResource.Email, EmailInput> RestView<AccountResource.Email>
This REST endpoint handles PUT
/accounts/<account-identifier>/emails/<email-identifier>
requests if the specified email doesn't
exist for the account yet. If it already exists, the request is handled by PutEmail
.
Whether an email address can be registered for the account depends on whether the used Realm
supports this.
When a new email address is registered an email with a confirmation link is sent to that
address. Only when the receiver confirms the email by clicking on the confirmation link, the
email address is added to the account (see ConfirmEmail
). Confirming an email address for an
account creates an external ID that links the email address to the account. An email address can
only be added to an account if it is not assigned to any other account yet.
In some cases it is allowed to skip the email confirmation and add the email directly (calling user has 'Modify Account' capability or server is running in dev mode).
-
Method Summary
Modifier and TypeMethodDescriptionapply
(AccountResource rsrc, IdString id, EmailInput input) Process the view operation by creating the resource.apply
(IdentifiedUser user, IdString id, EmailInput input) To be used from plugins that want to create emails without permission checks.
-
Method Details
-
apply
public Response<EmailInfo> apply(AccountResource rsrc, IdString id, EmailInput input) throws RestApiException, com.google.gerrit.exceptions.EmailException, MethodNotAllowedException, IOException, org.eclipse.jgit.errors.ConfigInvalidException, PermissionBackendException Description copied from interface:RestCollectionCreateView
Process the view operation by creating the resource.The returned response defines the status code that is returned to the client. For RestCollectionCreateViews this is usually
201 Created
because a resource is created, but other 2XX or 3XX status codes are also possible (e.g.Response.Redirect
can be returned for302 Found
).The value of the returned response is automatically converted to JSON unless it is a
BinaryResult
.Throwing a subclass of
RestApiException
results in a 4XX response to the client. For any other exception the client will get a500 Internal Server Error
response.- Specified by:
apply
in interfaceRestCollectionCreateView<AccountResource,
AccountResource.Email, EmailInput> - Parameters:
rsrc
- parent resource of the resource that should be createdid
- the ID of the child resource that should be createdinput
- input after parsing from request.- Returns:
- response to return to the client
- Throws:
RestApiException
- if the resource creation is rejectedcom.google.gerrit.exceptions.EmailException
MethodNotAllowedException
IOException
org.eclipse.jgit.errors.ConfigInvalidException
PermissionBackendException
-
apply
public EmailInfo apply(IdentifiedUser user, IdString id, EmailInput input) throws RestApiException, com.google.gerrit.exceptions.EmailException, MethodNotAllowedException, IOException, org.eclipse.jgit.errors.ConfigInvalidException, PermissionBackendException To be used from plugins that want to create emails without permission checks.- Throws:
RestApiException
com.google.gerrit.exceptions.EmailException
MethodNotAllowedException
IOException
org.eclipse.jgit.errors.ConfigInvalidException
PermissionBackendException
-