Package gwtappcontainer.server.apps.content

Examples of gwtappcontainer.server.apps.content.ContentAPI


  }
     
  @Test
  public void nonDevelopersCannotAddNewTag() {
           
    ContentAPI api = new ContentAPI();
    String tag = "tag_" + UUID.randomUUID();
   
    helper.loginAsPortalAdmin();
    User user = UserServiceFactory.getUserService().getCurrentUser();       
    APIResponse response = api.addNewTag(tag, user);
    assertTrue(response.statusCode == Status.ERROR_INSUFFICIENT_PERMISSION);
       
    helper.loginAsPortalReadOnly();
    user = UserServiceFactory.getUserService().getCurrentUser();   
    response = api.addNewTag(tag, user);
    assertTrue(response.statusCode == Status.ERROR_INSUFFICIENT_PERMISSION);
       
    helper.loginAsPortalUser();
    user = UserServiceFactory.getUserService().getCurrentUser();   
    response = api.addNewTag(tag, user);
    assertTrue(response.statusCode == Status.ERROR_INSUFFICIENT_PERMISSION);   
  }
View Full Code Here


    assertTrue(response.statusCode == Status.ERROR_INSUFFICIENT_PERMISSION);   
  }
 
  @Test
  public void cannotSetContentForInvalidTag() {
    ContentAPI api = new ContentAPI();
    String tag = "tag_" + UUID.randomUUID();
       
    APIResponse resp = api.setContent("test content", tag, true,
      helper.loginAsPortalAdmin());
    assertTrue(resp.statusCode == Status.ERROR_RESOURCE_DOES_NOT_EXIST);   
  }
View Full Code Here

  }
 
  @SuppressWarnings("unchecked")
  @Test
  public void canGetAllPublishedContents() {
    ContentAPI api = new ContentAPI();
       
    APIResponse response = api.getAllValidPublishedContents();
   
    //return code should be success, should be a map with no members
    assertTrue(response.statusCode == Status.SUCCESS);
   
    Map<String, String> published = (Map<String, String>) response.object;
    assertTrue(published.size() == 0);
   
    //add some tags and set contents       
    api.addNewTag("TEST", helper.loginAsDeveloper());
    api.addNewTag("test2", helper.loginAsDeveloper());
    api.addNewTag("teSt3", helper.loginAsDeveloper());
    api.addNewTag("test4", helper.loginAsDeveloper());
   
    api.setContent("content for test", "test", true, helper.loginAsPortalAdmin());
    api.setContent("content for test2", "test2", false, helper.loginAsPortalAdmin());
    api.setContent("content for test3", "test3", true, helper.loginAsPortalAdmin());
   
    response = api.setContent("content for test3", "", true,
      helper.loginAsPortalAdmin()); //invalid tag
    assertTrue(response.statusCode == Status.ERROR_RESOURCE_DOES_NOT_EXIST);
       
    response = api.getAllValidPublishedContents();
    assertTrue(response.statusCode == Status.SUCCESS);
   
    published = (Map<String, String>) response.object;
   
    assertTrue(published.size() == 2);
View Full Code Here

  }   
 
  @SuppressWarnings("unchecked")
  @Test
  public void onlyPortalAdminOrContentAdminCanSetPublishStatus() {
    ContentAPI contentAPI = new ContentAPI();
   
    contentAPI.addNewTag("testtag", helper.loginAsDeveloper());
    contentAPI.setContent("content html", "testtag", true,
        helper.loginAsPortalAdmin());
   
    APIResponse response = contentAPI.getAllValidPublishedContents();
    Map<String, String> all = (Map<String, String>) response.object; 
    assertTrue(all.containsKey("testtag"));
   
   
    //set publish to false
    contentAPI.setPublishStatus("testtag", false,
        helper.loginAsPortalAdmin());
    response = contentAPI.getAllValidPublishedContents();
    all = (Map<String, String>) response.object; 
    assertTrue(! all.containsKey("testtag"));
   
    //add a user as content admin
    AdminAPI adminAPI = new AdminAPI();
    adminAPI.addUser("contentadmin@test.com", helper.loginAsPortalAdmin());
    contentAPI.assignUserAsContentAdmin("contentadmin@test.com",
        "testtag", helper.loginAsPortalAdmin());
   
    //publish to true
    contentAPI.setPublishStatus("testtag", true,
        helper.loginAs("contentadmin@test.com"));
    response = contentAPI.getAllValidPublishedContents();
    all = (Map<String, String>) response.object; 
    assertTrue(all.containsKey("testtag"));
   
    //portaluser or portalreadonly should throw exception   
    response = contentAPI.setPublishStatus("testtag", false,
      helper.loginAsPortalReadOnly());
    assertTrue(response.statusCode == Status.ERROR_INSUFFICIENT_PERMISSION);
   
    response = contentAPI.setPublishStatus("testtag", false,
      helper.loginAsPortalUser());
    assertTrue(response.statusCode == Status.ERROR_INSUFFICIENT_PERMISSION);   
  }
View Full Code Here

    assertTrue(response.statusCode == Status.ERROR_INSUFFICIENT_PERMISSION);   
  }
 
  private void addNewTag(String tag) {
   
    ContentAPI contentApi = new ContentAPI();       
    contentApi.addNewTag(tag, helper.loginAsDeveloper());
  }
View Full Code Here

  public void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
   
    resp.setContentType("text/html");   
   
    ContentAPI contentAPI = new ContentAPI();
   
    final String PARAM_TAG = "tag";
    String tag = req.getParameter(PARAM_TAG);
   
    if (null == tag) {
      String errMessage = "Query param [" + PARAM_TAG + "] not found in query string";
      logger.warning(errMessage);
      resp.getWriter().println(errMessage);
      return;
    }
   
    APIResponse response = contentAPI.getContent(tag, null);
   
    if (response.statusCode != Status.SUCCESS) {     
      String errMessage = "Unable to retreive content. Reason(s) could be - <br>" +
          "1) Tag [" + tag + "] is invalid <br>" +
          "2) No content exists for tag [" + tag + "] <br>" +
View Full Code Here

    try {
      if (null == city) city = "";
      tag = tag.toLowerCase();
      city = city.toLowerCase();
     
      ContentAPI api = new ContentAPI();
     
      @SuppressWarnings("unchecked")
      Map<String, String> all =
        (Map<String, String>) api.getAllValidPublishedContents().object;
     
      //check if tag + "_" + city is present
      String tagForCity = tag + "_" + city;
      if (all.containsKey(tagForCity)) {
        return new APIResponse(Status.SUCCESS, all.get(tagForCity));
View Full Code Here

      tag = tag.toLowerCase();
      city = city.toLowerCase();
      region = region.toLowerCase();
      country = country.toLowerCase();
     
      ContentAPI api = new ContentAPI();
     
      @SuppressWarnings("unchecked")
      Map<String, String> all =
        (Map<String, String>) api.getAllValidPublishedContents().object;
     
      //check if tag + "_" + city is present
      String tagForCity = tag + "_" + city;
      if (all.containsKey(tagForCity)) {
        return new APIResponse(Status.SUCCESS,
View Full Code Here

    helper.tearDown();
  }
 
  @Test
  public void canGetCityContent() {
    ContentAPI contentAPI = new ContentAPI();
   
    contentAPI.addNewTag("ishakriyaschedule_mumbai", helper.loginAsDeveloper());
    contentAPI.setContent("content for mumbai", "ishakriyaschedule_mumbai", true, helper.loginAsPortalAdmin());
   
    GeoLocationAPI geoApi = new GeoLocationAPI();
    String content = geoApi.getContentForCity("ishakriyaschedule", "mumbai").object.toString();
    assertTrue(content.equals("content for mumbai"));               
  }
View Full Code Here

    assertTrue(content.equals("content for mumbai"));               
  }
 
  @Test
  public void cityAndTagAreCaseInsensitive() {
    ContentAPI contentAPI = new ContentAPI();
   
    contentAPI.addNewTag("ishakriyaschedule_mumbai", helper.loginAsDeveloper());
    contentAPI.setContent("content for mumbai", "ishakriyaschedule_mumbai", true, helper.loginAsPortalAdmin());
   
    GeoLocationAPI geoApi = new GeoLocationAPI();
    String content = geoApi.getContentForCity("ishakriyASchedule", "mUMBAi").object.toString();
    assertTrue(content.equals("content for mumbai"));
  }
View Full Code Here

TOP

Related Classes of gwtappcontainer.server.apps.content.ContentAPI

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.