// Path: smssync/src/main/java/org/addhen/smssync/data/exception/WebServiceNotFoundException.java
// public class WebServiceNotFoundException extends Exception {
// 
//     /**
//      * Default exception
//      */
//     public WebServiceNotFoundException() {
//         super();
//     }
// 
//     /**
//      * Initialize the exception with a custom message
//      *
//      * @param message The message be shown when the exception is thrown
//      */
//     public WebServiceNotFoundException(final String message) {
//         super(message);
//     }
// 
//     /**
//      * Initialize the exception with a custom message and the cause of the exception
//      *
//      * @param message The message to be shown when the exception is thrown
//      * @param cause   The cause of the exception
//      */
//     public WebServiceNotFoundException(final String message, final Throwable cause) {
//         super(message, cause);
//     }
// 
//     /**
//      * Initialize the exception with a the cause of the exception
//      *
//      * @param cause The cause of the exception
//      */
//     public WebServiceNotFoundException(final Throwable cause) {
//         super(cause);
//     }
// }


import static nl.qbusict.cupboard.CupboardFactory.cupboard;
import org.addhen.smssync.data.entity.SyncUrl;
import org.addhen.smssync.data.exception.WebServiceNotFoundException;
import android.content.Context;
import android.support.annotation.NonNull;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import rx.Observable;
     * @return An Observable that emits a list of {@link SyncUrl}
     */
    public Observable<List<SyncUrl>> getWebServices() {
        return Observable.create(subscriber -> {
            final List<SyncUrl> syncUrls = cupboard()
                    .withDatabase(getReadableDatabase()).query(SyncUrl.class).list();
            if (syncUrls != null) {
                subscriber.onNext(syncUrls);
                subscriber.onCompleted();
            } else {
                subscriber.onError(new WebServiceNotFoundException());
            }
        });
    }

    /**
     * Gets a webService
     *
     * @param id The ID of the webService to retrieve
     * @return An Observable that emits a {@link SyncUrl}
     */
    public Observable<SyncUrl> getWebService(Long id) {
        return Observable.create(subscriber -> {
            final SyncUrl syncUrlEntity = cupboard().withDatabase(getReadableDatabase())
                    .query(SyncUrl.class)
                    .byId(id).get();
            if (syncUrlEntity != null) {
                subscriber.onNext(syncUrlEntity);
                subscriber.onCompleted();
            } else {
// Path: smssync/src/main/java/org/addhen/smssync/data/exception/WebServiceNotFoundException.java
// public class WebServiceNotFoundException extends Exception {
// 
//     /**
//      * Default exception
//      */
//     public WebServiceNotFoundException() {
//         super();
//     }
// 
//     /**
//      * Initialize the exception with a custom message
//      *
//      * @param message The message be shown when the exception is thrown
//      */
//     public WebServiceNotFoundException(final String message) {
//         super(message);
//     }
// 
//     /**
//      * Initialize the exception with a custom message and the cause of the exception
//      *
//      * @param message The message to be shown when the exception is thrown
//      * @param cause   The cause of the exception
//      */
//     public WebServiceNotFoundException(final String message, final Throwable cause) {
//         super(message, cause);
//     }
// 
//     /**
//      * Initialize the exception with a the cause of the exception
//      *
//      * @param cause The cause of the exception
//      */
//     public WebServiceNotFoundException(final Throwable cause) {
//         super(cause);
//     }
// }


// Path: smssync/src/main/java/org/addhen/smssync/data/database/WebServiceDatabaseHelper.java
import static nl.qbusict.cupboard.CupboardFactory.cupboard;
import org.addhen.smssync.data.entity.SyncUrl;
import org.addhen.smssync.data.exception.WebServiceNotFoundException;
import android.content.Context;
import android.support.annotation.NonNull;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Singleton;
import rx.Observable;

     * @return An Observable that emits a list of {@link SyncUrl}
     */
    public Observable<List<SyncUrl>> getWebServices() {
        return Observable.create(subscriber -> {
            final List<SyncUrl> syncUrls = cupboard()
                    .withDatabase(getReadableDatabase()).query(SyncUrl.class).list();
            if (syncUrls != null) {
                subscriber.onNext(syncUrls);
                subscriber.onCompleted();
            } else {
                subscriber.onError(new WebServiceNotFoundException());
            }
        });
    }

    /**
     * Gets a webService
     *
     * @param id The ID of the webService to retrieve
     * @return An Observable that emits a {@link SyncUrl}
     */
    public Observable<SyncUrl> getWebService(Long id) {
        return Observable.create(subscriber -> {
            final SyncUrl syncUrlEntity = cupboard().withDatabase(getReadableDatabase())
                    .query(SyncUrl.class)
                    .byId(id).get();
            if (syncUrlEntity != null) {
                subscriber.onNext(syncUrlEntity);
                subscriber.onCompleted();
            } else {
                subscriber.onError(new WebServiceNotFoundException());