private void handleUpdate()

in server/protocols/jmap-draft/src/main/java/org/apache/james/jmap/draft/methods/SetMailboxesUpdateProcessor.java [93:156]


    private void handleUpdate(MailboxId mailboxId, MailboxUpdateRequest updateRequest, Builder responseBuilder, MailboxSession mailboxSession) {
        try {
            validateMailboxName(updateRequest, mailboxSession);
            Mailbox mailbox = getMailbox(mailboxId, mailboxSession);
            assertNotSharedOutboxOrDraftMailbox(mailbox, updateRequest);
            assertSystemMailboxesAreNotUpdated(mailbox, updateRequest);
            validateParent(mailbox, updateRequest, mailboxSession);

            updateMailbox(mailbox, updateRequest, mailboxSession);
            responseBuilder.updated(mailboxId);

        } catch (SystemMailboxNotUpdatableException e) {
            responseBuilder.notUpdated(mailboxId, SetError.builder()
                    .type(SetError.Type.INVALID_ARGUMENTS)
                    .description("Cannot update a system mailbox.")
                    .build());
        } catch (TooLongMailboxNameException e) {
            responseBuilder.notUpdated(mailboxId, SetError.builder()
                .type(SetError.Type.INVALID_ARGUMENTS)
                .description("The mailbox name length is too long")
                .build());
        } catch (MailboxNameException | IllegalArgumentException e) {
            responseBuilder.notUpdated(mailboxId, SetError.builder()
                    .type(SetError.Type.INVALID_ARGUMENTS)
                    .description(e.getMessage())
                    .build());
        } catch (MailboxNotFoundException e) {
            responseBuilder.notUpdated(mailboxId, SetError.builder()
                    .type(SetError.Type.NOT_FOUND)
                    .description(String.format("The mailbox '%s' was not found", mailboxId.serialize()))
                    .build());
        } catch (MailboxParentNotFoundException e) {
            responseBuilder.notUpdated(mailboxId, SetError.builder()
                    .type(SetError.Type.NOT_FOUND)
                    .description(String.format("The parent mailbox '%s' was not found.", e.getParentId()))
                    .build());
        } catch (MailboxHasChildException e) {
            responseBuilder.notUpdated(mailboxId, SetError.builder()
                    .type(SetError.Type.INVALID_ARGUMENTS)
                    .description("Cannot update a parent mailbox.")
                    .build());
        } catch (MailboxNotOwnedException e) {
            responseBuilder.notUpdated(mailboxId, SetError.builder()
                    .type(SetError.Type.INVALID_ARGUMENTS)
                    .description("Parent mailbox is not owned.")
                    .build());
        } catch (MailboxExistsException e) {
            responseBuilder.notUpdated(mailboxId, SetError.builder()
                    .type(SetError.Type.INVALID_ARGUMENTS)
                    .description("Cannot rename a mailbox to an already existing mailbox.")
                    .build());
        } catch (DifferentDomainException e) {
            responseBuilder.notUpdated(mailboxId, SetError.builder()
                .type(SetError.Type.INVALID_ARGUMENTS)
                .description("Cannot share a mailbox to another domain")
                .build());
        } catch (MailboxException e) {
            LOGGER.error("Error while updating mailbox", e);
            responseBuilder.notUpdated(mailboxId, SetError.builder()
                    .type(SetError.Type.ERROR)
                    .description("An error occurred when updating the mailbox")
                    .build());
        }
    }