/** * Use template method to centralize and ensure common validation */ public void handleCommand(Command command, Session session) { Assert.notNull(serverConfiguration, "serverConfiguration"); Assert.notNull(command, "command"); Assert.notNull(session, "session"); try { handle(command, session); } catch (CommandSyntaxException e) { handleException(command, session, e, ReplyCodes.COMMAND_SYNTAX_ERROR); } catch (IllegalStateException e) { handleException(command, session, e, ReplyCodes.ILLEGAL_STATE); } catch (NotLoggedInException e) { handleException(command, session, e, ReplyCodes.NOT_LOGGED_IN); } catch (InvalidFilenameException e) { handleFileSystemException(command, session, e, ReplyCodes.FILENAME_NOT_VALID, e.getPath()); } catch (FileSystemException e) { handleFileSystemException(command, session, e, replyCodeForFileSystemException, e.getPath()); } }