Repository: james-project Updated Branches: refs/heads/master 1f3d5c8f2 -> b2f2e187c
JAMES-1721 Enhance readability of SetMailboxesUpdateProcessor class by removing an abstraction level and using existing Builder Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/80c60012 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/80c60012 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/80c60012 Branch: refs/heads/master Commit: 80c60012529b0d2ad3b7605469bff26cb0926020 Parents: f476cba Author: Laura Royet <lro...@linagora.com> Authored: Tue Apr 19 15:55:47 2016 +0200 Committer: Laura Royet <lro...@linagora.com> Committed: Mon Apr 25 14:50:28 2016 +0200 ---------------------------------------------------------------------- .../methods/SetMailboxesUpdateProcessor.java | 48 ++++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/80c60012/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesUpdateProcessor.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesUpdateProcessor.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesUpdateProcessor.java index b079b64..0eee160 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesUpdateProcessor.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/methods/SetMailboxesUpdateProcessor.java @@ -80,25 +80,40 @@ public class SetMailboxesUpdateProcessor<Id extends MailboxId> implements SetMai responseBuilder.updated(mailboxId); } catch (SystemMailboxNotUpdatableException e) { - notUpdated(mailboxId, "invalidArguments", "Cannot update a system mailbox.", responseBuilder); + responseBuilder.notUpdated(mailboxId, SetError.builder() + .type("invalidArguments") + .description("Cannot update a system mailbox.") + .build()); } catch (MailboxNameException e) { - notUpdated(mailboxId, "invalidArguments", - e.getMessage(), responseBuilder); + responseBuilder.notUpdated(mailboxId, SetError.builder() + .type("invalidArguments") + .description(e.getMessage()) + .build()); } catch (MailboxNotFoundException e) { - notUpdated(mailboxId, "notFound", - String.format("The mailbox '%s' was not found", mailboxId), responseBuilder); + responseBuilder.notUpdated(mailboxId, SetError.builder() + .type("notFound") + .description(String.format("The mailbox '%s' was not found", mailboxId)) + .build()); } catch (MailboxParentNotFoundException e) { - notUpdated(mailboxId, "notFound", - String.format("The parent mailbox '%s' was not found.", e.getParentId()), responseBuilder); + responseBuilder.notUpdated(mailboxId, SetError.builder() + .type("notFound") + .description(String.format("The parent mailbox '%s' was not found.", e.getParentId())) + .build()); } catch (MailboxHasChildException e) { - notUpdated(mailboxId, "invalidArguments", - "Cannot update a parent mailbox.", responseBuilder); + responseBuilder.notUpdated(mailboxId, SetError.builder() + .type("invalidArguments") + .description("Cannot update a parent mailbox.") + .build()); } catch (MailboxExistsException e) { - notUpdated(mailboxId, "invalidArguments", - "Cannot rename a mailbox to an already existing mailbox.", responseBuilder); + responseBuilder.notUpdated(mailboxId, SetError.builder() + .type("invalidArguments") + .description("Cannot rename a mailbox to an already existing mailbox.") + .build()); } catch (MailboxException e) { - notUpdated(mailboxId, "anErrorOccurred", - "An error occurred when updating the mailbox", responseBuilder); + responseBuilder.notUpdated(mailboxId, SetError.builder() + .type( "anErrorOccurred") + .description("An error occurred when updating the mailbox") + .build()); } } @@ -108,13 +123,6 @@ public class SetMailboxesUpdateProcessor<Id extends MailboxId> implements SetMai } } - private Builder notUpdated(String mailboxId, String type, String message, Builder responseBuilder) { - return responseBuilder.notUpdated(mailboxId, SetError.builder() - .type(type) - .description(message) - .build()); - } - private Mailbox getMailbox(String mailboxId, MailboxSession mailboxSession) throws MailboxNotFoundException { return mailboxUtils.mailboxFromMailboxId(mailboxId, mailboxSession) .orElseThrow(() -> new MailboxNotFoundException(mailboxId)); --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org