Convenience Methods for Account Stores

Agree. I think this approach is the best one. I am implementing it now.
Thanks!
On Oct 27, 2014 6:18 PM, "Les Hazlewood" <notifications@github.com> wrote:

> In api/src/main/java/com/stormpath/sdk/application/Application.java:
>
> > +     * <p/>
> > +     * <pre>
> > +     *      Directory directory = client.instantiate(Directory.class);
> > +     *      directory.setName("Foo Directory");
> > +     *      AccountStoreMapping accountStoreMapping = application.addDirectory(directory);
> > +     * </pre>
> > +     * <b>Usage NOTE:</b> Unlike other methods in this class that require the {@link #save()} method to be called to
> > +     * persist changes, this is a convenience method and will call the server immediately.
> > +     *
> > +     * @param directory the given {@link Directory} instance having either the href or the name specified.
> > +     * @return the {@link AccountStoreMapping} created after finding the actual directory pertaining to this tenant
> > +     *          that matches either the given Href or name. It returns null if there is no directory matching the href or name.
> > +     * @throws ResourceException if the given directory already exists as an account store in this application.
> > +     * @since 1.0.0
> > +     */
> > +    AccountStoreMapping addDirectory(Directory directory);
>
> Do we need to modify the existing addAccountStore(AccountStore) method?
> Why not create an overloaded method:
>
> addAccountStore(String hrefOrName)
>
> If it is not an href, it is equivalent to searching by name. If more than
> one result is returned, we must throw an exception.
>
> Thoughts?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/stormpath/stormpath-sdk-java/pull/104/files#r19437971>
> .
>