Search in sources :

Example 1 with OsmAuthorizationException

use of de.westnordost.osmapi.common.errors.OsmAuthorizationException in project StreetComplete by westnordost.

the class QuestChangesUploadService method onHandleIntent.

@Override
protected void onHandleIntent(Intent intent) {
    if (cancelState.get())
        return;
    try {
        if (isBanned()) {
            throw new VersionBannedException(banReason);
        }
        // let's fail early in case of no authorization
        if (!oAuth.isAuthorized()) {
            throw new OsmAuthorizationException(401, "Unauthorized", "User is not authorized");
        }
        Log.i(TAG, "Starting upload changes");
        OsmNoteQuestChangesUpload noteQuestUpload = noteQuestUploadProvider.get();
        noteQuestUpload.upload(cancelState);
        if (cancelState.get())
            return;
        UndoOsmQuestChangesUpload undoOsmQuestUpload = undoQuestUploadProvider.get();
        undoOsmQuestUpload.setVisibleQuestListener(visibleQuestRelay);
        undoOsmQuestUpload.upload(cancelState);
        if (cancelState.get())
            return;
        OsmQuestChangesUpload osmQuestUpload = questUploadProvider.get();
        osmQuestUpload.setVisibleQuestListener(visibleQuestRelay);
        osmQuestUpload.upload(cancelState);
        if (cancelState.get())
            return;
        CreateNoteUpload createNoteUpload = createNoteUploadProvider.get();
        createNoteUpload.upload(cancelState);
    } catch (Exception e) {
        Log.e(TAG, "Unable to upload changes", e);
        if (progressListener != null) {
            progressListener.onError(e);
        }
    }
    if (progressListener != null) {
        progressListener.onFinished();
    }
    Log.i(TAG, "Finished upload changes");
}
Also used : UndoOsmQuestChangesUpload(de.westnordost.streetcomplete.data.osm.upload.UndoOsmQuestChangesUpload) OsmQuestChangesUpload(de.westnordost.streetcomplete.data.osm.upload.OsmQuestChangesUpload) OsmAuthorizationException(de.westnordost.osmapi.common.errors.OsmAuthorizationException) CreateNoteUpload(de.westnordost.streetcomplete.data.osmnotes.CreateNoteUpload) UndoOsmQuestChangesUpload(de.westnordost.streetcomplete.data.osm.upload.UndoOsmQuestChangesUpload) OsmNoteQuestChangesUpload(de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestChangesUpload) IOException(java.io.IOException) OsmAuthorizationException(de.westnordost.osmapi.common.errors.OsmAuthorizationException)

Aggregations

OsmAuthorizationException (de.westnordost.osmapi.common.errors.OsmAuthorizationException)1 OsmQuestChangesUpload (de.westnordost.streetcomplete.data.osm.upload.OsmQuestChangesUpload)1 UndoOsmQuestChangesUpload (de.westnordost.streetcomplete.data.osm.upload.UndoOsmQuestChangesUpload)1 CreateNoteUpload (de.westnordost.streetcomplete.data.osmnotes.CreateNoteUpload)1 OsmNoteQuestChangesUpload (de.westnordost.streetcomplete.data.osmnotes.OsmNoteQuestChangesUpload)1 IOException (java.io.IOException)1