Package org.apache.shindig.protocol

Examples of org.apache.shindig.protocol.ProtocolException


            }
          }

          // Error - MediaItem ID not found
          if (!found) {
            throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "MediaItem ID " + mediaItemId + " does not exist within Album " + albumId);
          }
        }

        // Return found MediaItems
        return ImmediateFuture.newInstance(new RestfulCollection<MediaItem>(result));
      }

      // Table doesn't exist for user
      throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "MediaItem table not found for user " + user);
    } catch (JSONException je) {
      throw new ProtocolException(
          HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
          je.getMessage(), je);
    }
  }
View Full Code Here


        // Return found MediaItems
        return ImmediateFuture.newInstance(new RestfulCollection<MediaItem>(result));
      }

      // Album wasn't found
      throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Album ID " + albumId + " does not exist");
    } catch (JSONException je) {
      throw new ProtocolException(
          HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
          je.getMessage(), je);
    }
  }
View Full Code Here

          }
        }
      }
      return ImmediateFuture.newInstance(new RestfulCollection<MediaItem>(result));
    } catch (JSONException je) {
      throw new ProtocolException(
          HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
          je.getMessage(), je);
    }
  }
View Full Code Here

      // Overwrite user's MediaItems with updated list if target found
      if (targetFound) {
        db.getJSONObject(MEDIAITEMS_TABLE).put(user, newMediaItems);
        return ImmediateFuture.newInstance(null);
      } else {
        throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "MediaItem ID " + mediaItemId + " does not exist existin within Album " + albumId);
      }
    } catch (JSONException je) {
      throw new ProtocolException(
          HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
          je.getMessage(), je);
    }
  }
View Full Code Here

      // Insert new MediaItem into table
      userMediaItems.put(jsonMediaItem);
      return ImmediateFuture.newInstance(null);
    } catch (JSONException je) {
      throw new ProtocolException(
          HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
          je.getMessage(), je);
    }
  }
View Full Code Here

          }
        }
      }

      // Error - no MediaItem found with given ID and Album ID
      throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "MediaItem ID " + mediaItemId + " does not exist existin within Album " + albumId);
    } catch (JSONException je) {
      throw new ProtocolException(
          HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
          je.getMessage(), je);
    }
  }
View Full Code Here

        if (entry.getString(ActivityEntry.Field.ID.toString()).equals(activityId)) {
          jsonArray.put(i, jsonEntry);
          return ImmediateFuture.newInstance(filterFields(jsonEntry, fields, ActivityEntry.class));
        }
      }
      throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Activity not found: " + activityId);
    } catch (JSONException je) {
      throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, je.getMessage(), je);
    }
  }
View Full Code Here

      // Ensure activity does not already exist
      for (int i = 0; i < jsonArray.length(); i++) {
        JSONObject entry = jsonArray.getJSONObject(i);
        if (entry.getString(ActivityEntry.Field.ID.toString()).equals(activityId)) {
          throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Activity already exists: " + activityId);
        }
      }
      jsonArray.put(jsonEntry);
      return ImmediateFuture.newInstance(filterFields(jsonEntry, fields, ActivityEntry.class));
    } catch (JSONException je) {
      throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, je.getMessage(), je);
    }
  }
View Full Code Here

          db.getJSONObject(ACTIVITYSTREAMS_TABLE).put(user, newList);
        }
      }
      return ImmediateFuture.newInstance(null);
    } catch (JSONException je) {
      throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, je.getMessage(), je);
    }
  }
View Full Code Here

          if (activityEntry.getString(ActivityEntry.Field.ID.toString()).equals(activityId)) {
            return ImmediateFuture.newInstance(filterFields(activityEntry, fields, ActivityEntry.class));
          }
        }
      }
      throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Activity not found: " + activityId);
    } catch (JSONException je) {
      throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, je.getMessage(), je);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.protocol.ProtocolException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.