/** Test method read */
 @Test
 public void testReadPodcast() {
   final Feed readPodcast = feedManager.getFeed(feed);
   assertNotNull(readPodcast);
   assertNotNull(readPodcast.getId());
   assertEquals(PODCAST_TITLE, readPodcast.getTitle());
 }
  /** Test method create */
  @Test
  public void testCreatePodcast() {
    final OLATResourceable podcastResource = feedManager.createPodcastResource();
    final Feed newPodcast = feedManager.getFeed(podcastResource);
    assertNotNull(newPodcast);
    assertNotNull(newPodcast.getId());

    // Has a feed folder been created?
    final VFSContainer podcastContainer = feedManager.getFeedContainer(newPodcast);
    assertNotNull(podcastContainer);
    feedManager.delete(newPodcast);
  }
Пример #3
0
 // update feed
 public void updateFeed(Feed feed) throws CosmException {
   try {
     HttpPut hr =
         new HttpPut(
             API_BASE_URL_V2 + API_RESOURCE_FEEDS + "/" + feed.getId() + JSON_FILE_EXTENSION);
     hr.setEntity(new StringEntity(feed.toJSONObject().toString()));
     HttpResponse response = this.client.execute(hr);
     StatusLine statusLine = response.getStatusLine();
     if (statusLine.getStatusCode() != 200) {
       throw new CosmException(response.getStatusLine().toString());
     }
   } catch (Exception e) {
     e.printStackTrace();
     throw new CosmException("Caught exception in create Feed");
   }
 }
Пример #4
0
  @POST
  @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public SheetViewModelCollection getSheets(@Context HttpServletRequest req) {
    if (!Authenticate.authenticateHeader(req)) {
      return null;
    }

    SheetController sheetController = new SheetController();
    sheetvector sheets =
        sheetController.GetSheetsByUsername(Authenticate.getAuthRequest(req).getUsername());

    ContentPlaceholderController cphController = new ContentPlaceholderController();
    FeedController feedc = new FeedController();
    ItemController itemc = new ItemController();

    List<SheetViewModel> models = new ArrayList<SheetViewModel>();

    int sheetLen = (int) sheets.size();
    for (int i = 0; i < sheetLen; i++) {
      boolean column1 = false;
      boolean column2 = false;

      List<newsfeeder.lib.model.ContentPlaceholder> contentPlaceholders =
          new ArrayList<newsfeeder.lib.model.ContentPlaceholder>();

      Sheet s = sheets.get(i);
      cphvector cphs = cphController.GetContentPlaceholdersBySheetId(s.getId());

      int cphLen = (int) cphs.size();
      for (int x = 0; x < cphLen; x++) {
        nfdb.ContentPlaceholder cph = cphs.get(x);

        NewsContentPlaceholder newsCPH =
            new NewsContentPlaceholder(cph.getColumn(), cph.getOrder());
        contentPlaceholders.add(newsCPH);

        if (cph.getColumn() == 0) {
          column1 = true;
        }

        if (cph.getColumn() == 1) {
          column2 = true;
        }

        feedvector feeds = feedc.GetFeedsByCphId(cph.getId());
        int feedLen = (int) feeds.size();

        for (int y = 0; y < feedLen; y++) {
          Feed f = feeds.get(y);

          itemvector items = itemc.GetItemsByFeedId(f.getId());
          int itemLen = (int) items.size();
          for (int z = 0; z < itemLen; z++) {
            nfdb.Item dbItem = items.get(z);

            NewsItem item =
                new NewsItem(dbItem.getId(), dbItem.getContent(), dbItem.getTitle(), "");
            newsCPH.addItem(item);
          }
        }
      }

      SheetLayout layout = get2ColLayout();

      if (column1 && column2) {
        layout = get2ColLayout();
      } else if (column1) {
        layout = get1ColLayout(0);
      } else if (column2) {
        layout = get1ColLayout(1);
      }

      SheetViewModel model =
          new SheetViewModel(s.getId(), s.getName(), layout, contentPlaceholders);
      models.add(model);
    }

    SheetViewModelCollection collection = new SheetViewModelCollection();
    collection.Sheets = (ArrayList<SheetViewModel>) models;

    return collection;
  }