Package gwtappcontainer.server.apis.admin

Examples of gwtappcontainer.server.apis.admin.AdminAPI


    APIResponse resp = contentApi.assignUserAsContentAdmin(email,
        tag, user);
    assertTrue(resp.statusCode == Status.SUCCESS);
   
    //check if role exists
    AdminAPI adminApi = new AdminAPI();
    resp = adminApi.getRolesForUser(email);
    UserProp prop = (UserProp) resp.object;
   
    String role = Roles.CONTENT_ADMIN_PREFIX + tag.toUpperCase();
    assertTrue(Util.isRolePresent(prop.roles, role));       
  }
View Full Code Here


    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,
View Full Code Here

    contentApi.addNewTag(tag, helper.loginAsDeveloper());
  }
 
  private void addNewUser(String email) {
       
    AdminAPI adminApi = new AdminAPI();

    adminApi.addUser(email, helper.loginAsPortalAdmin());
 
View Full Code Here

  @ApiMethod(path="assignuserascontentadmin", httpMethod = HttpMethod.PUT)
  public APIResponse assignUserAsContentAdmin(@Named("email") String email,
      @Named("tag") String tag, User user) {
     
    try {
      AdminAPI adminAPI = new AdminAPI();
      String role = getContentAdminRoleForTag(tag);
     
      APIResponse resp = adminAPI.assignRoleToUser(email, role, user);
     
      return resp; 
    } catch (Exception ex) {
      return new APIResponse(ex);
    }
View Full Code Here

  public APIResponse addNewTag(@Named("content_tag") String tag, User user) {
    try {       
      //only DEVELOPER can add tag
      ensureRole(user, Role.DEVELOPER)
     
      AdminAPI adminAPI = new AdminAPI();
      String role = getContentAdminRoleForTag(tag);
      APIResponse resp = adminAPI.addRole(role, user);
     
      return resp;
    } catch (Exception ex) {
      return new APIResponse(ex);
    }
View Full Code Here

  }
 
  @ApiMethod(path="getalltags", httpMethod = HttpMethod.GET)
  public APIResponse getAllTags() {
    try {
      AdminAPI adminAPI = new AdminAPI();
      APIResponse resp = adminAPI.getAllRoles();
     
      @SuppressWarnings("unchecked")
      List<RoleProp> roles = (List<RoleProp>) resp.object;
     
      List<String> tags = getTagsFromRoles(roles);
View Full Code Here

        //dsHelper.tearDown();       
    }
   
    @Test
    public void anyUserModificationWithoutLoginGivesAuthenticationError() {
      AdminAPI api = new AdminAPI();
     
      APIResponse resp = api.addUser("dummy@dummy.com", null);
      assertTrue(resp.statusCode == Status.ERROR_LOGIN_REQUIRED);
     
      try {
      resp = api.assignRoleToUser("dummy", "dummy", null);
      } catch (APIException ex) {
        assertTrue(ex.statusCode == Status.ERROR_LOGIN_REQUIRED);
      }
     
      resp = api.unassignRoleToUser("dummy", "dummy", null);
      assertTrue(resp.statusCode == Status.ERROR_LOGIN_REQUIRED);
    }
View Full Code Here

    @Test
    public void adminCanAddUserAssignUnassignRole() {
      MockGateKeeper mockGateKeeper = new MockGateKeeper();
      mockGateKeeper.allowRoleToUser("test@example.com", Role.PORTAL_ADMIN);
      mockGateKeeper.allowRoleToUser("test@example.com", Role.DEVELOPER);
      AdminAPI api = new AdminAPI();
      api.setGateKeeper(mockGateKeeper);
     
      User user = UserServiceFactory.getUserService().getCurrentUser();
     
      String email = "dummy_" + UUID.randomUUID() + "@dummy.com";
      APIResponse resp = api.addUser(email, user);
      assertTrue(resp.statusCode == Status.SUCCESS);
     
      //first add role
      String role = "role_" + UUID.randomUUID();
      resp = api.addRole(role, user);
      assertTrue(resp.statusCode == Status.SUCCESS);
     
      resp = api.assignRoleToUser(email, role, user);
      assertTrue(resp.statusCode == Status.SUCCESS);
     
      resp = api.unassignRoleToUser(email, role, user);
      assertTrue(resp.statusCode == Status.SUCCESS);
    }
View Full Code Here

    @Test
    public void assigningExistingRoleGivesResourceAlreadyExistsError() {
      MockGateKeeper mockGateKeeper = new MockGateKeeper();
      mockGateKeeper.allowRoleToUser("test@example.com", Role.PORTAL_ADMIN);
      mockGateKeeper.allowRoleToUser("test@example.com", Role.DEVELOPER);
      AdminAPI api = new AdminAPI();
      api.setGateKeeper(mockGateKeeper);
     
      User user = UserServiceFactory.getUserService().getCurrentUser();
     
      String email = "dummy_" + UUID.randomUUID() + "@dummy.com";
      APIResponse resp = api.addUser(email, user);
      assertTrue(resp.statusCode == Status.SUCCESS);
     
      //first add role
      String role = "role_" + UUID.randomUUID();
      resp = api.addRole(role, user);
      assertTrue(resp.statusCode == Status.SUCCESS);
     
      resp = api.assignRoleToUser(email, role, user);
      assertTrue(resp.statusCode == Status.SUCCESS);
     
      //try to assign again
      try {
        resp = api.assignRoleToUser(email, role, user);
      } catch (APIException ex) {   
        assertTrue(ex.statusCode == Status.ERROR_RESOURCE_ALREADY_EXISTS);
      }
    }
View Full Code Here

    @Test
    public void unassigningNonExistantRoleGivesResourceNotFoundError() {
      MockGateKeeper mockGateKeeper = new MockGateKeeper();
      mockGateKeeper.allowRoleToUser("test@example.com", Role.PORTAL_ADMIN);
      mockGateKeeper.allowRoleToUser("test@example.com", Role.DEVELOPER);
      AdminAPI api = new AdminAPI();
      api.setGateKeeper(mockGateKeeper);
     
      User user = UserServiceFactory.getUserService().getCurrentUser();
     
      String email = "dummy_" + UUID.randomUUID() + "@dummy.com";
      APIResponse resp = api.addUser(email, user);
      assertTrue(resp.statusCode == Status.SUCCESS);
     
      //first add role
      String role = "role_" + UUID.randomUUID();
      resp = api.addRole(role, user);
      assertTrue(resp.statusCode == Status.SUCCESS);
     
      resp = api.assignRoleToUser(email, role, user);
      assertTrue(resp.statusCode == Status.SUCCESS);
     
      resp = api.unassignRoleToUser(email, role, user);
      assertTrue(resp.statusCode == Status.SUCCESS);
     
      //try to unassign again
      resp = api.unassignRoleToUser(email, role, user);
      assertTrue(resp.statusCode == Status.ERROR_RESOURCE_DOES_NOT_EXIST);           
    }
View Full Code Here

TOP

Related Classes of gwtappcontainer.server.apis.admin.AdminAPI

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.