test_class.declarator: restExtJsService
test_class.modifier: private
test_class.original_string: private RESTExtJsServiceImpl restExtJsService;
test_class.type: RESTExtJsServiceImpl
test_class.var_name: restExtJsService
test_class.file: src/modules/rest/extjs/src/test/java/it/geosolutions/geostore/services/rest/impl/RESTExtJsServiceImplTest.java
test_class.identifier: RESTExtJsServiceImplTest
test_class.superclass: extends ServiceTestBase
test_case.body: @Test
      public void testGetAllResources_auth_base() throws Exception
      {
          final String CAT_NAME = "CAT000";
  
          assertEquals(0, resourceService.getAll(null, null, buildFakeAdminUser()).size());
  
          long u0 = restCreateUser("u0", Role.USER, "p0");
          long u1 = restCreateUser("u1", Role.USER, "p1");
  
          Category cat = createCategory(CAT_NAME);
  
          restCreateResource("r_u0_0", "x", CAT_NAME, u0);
  
          restCreateResource("r_u1_0", "x", CAT_NAME, u1);
          restCreateResource("r_u1_1", "x", CAT_NAME, u1);
  
          {
              SecurityContext sc = new SimpleSecurityContext(u0);
              String response = restExtJsService.getAllResources(sc, "*", 0, 1000);
  
              System.out.println("JSON " + response);
  
              JSONResult result = parse(response);
              assertEquals(1, result.total);
              assertEquals(1, result.returnedCount);
  
              assertTrue(result.names.contains("r_u0_0"));
          }
  
          {
              SecurityContext sc = new SimpleSecurityContext(u1);
              String response = restExtJsService.getAllResources(sc, "*", 0, 1000);
  
              System.out.println("JSON " + response);
  
              JSONResult result = parse(response);
              assertEquals(2, result.total);
              assertEquals(2, result.returnedCount);
  
              assertTrue(result.names.contains("r_u1_0"));
              assertTrue(result.names.contains("r_u1_1"));
  
              assertFalse(result.names.contains("r_u0_0"));
          }
      }
test_case.class_method_signature: RESTExtJsServiceImplTest.testGetAllResources_auth_base()
test_case.full_signature: @Test public void testGetAllResources_auth_base()
test_case.identifier: testGetAllResources_auth_base
test_case.invocations: assertEquals size getAll buildFakeAdminUser restCreateUser restCreateUser createCategory restCreateResource restCreateResource restCreateResource getAllResources println parse assertEquals assertEquals assertTrue contains getAllResources println parse assertEquals assertEquals assertTrue contains assertTrue contains assertFalse contains
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetAllResources_auth_base()
focal_class.declarator: LOGGER = Logger.getLogger(RESTExtJsServiceImpl.class)
focal_class.modifier: private final static
focal_class.original_string: private final static Logger LOGGER = Logger.getLogger(RESTExtJsServiceImpl.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: resourceService
focal_class.modifier: private
focal_class.original_string: private ResourceService resourceService;
focal_class.type: ResourceService
focal_class.var_name: resourceService
focal_class.declarator: userService
focal_class.modifier: private
focal_class.original_string: private UserService userService;
focal_class.type: UserService
focal_class.var_name: userService
focal_class.declarator: groupService
focal_class.modifier: private
focal_class.original_string: private UserGroupService groupService;
focal_class.type: UserGroupService
focal_class.var_name: groupService
focal_class.file: src/modules/rest/extjs/src/main/java/it/geosolutions/geostore/services/rest/impl/RESTExtJsServiceImpl.java
focal_class.identifier: RESTExtJsServiceImpl
focal_class.interfaces: implements RESTExtJsService
focal_class.class_method_signature: RESTExtJsServiceImpl.setResourceService(ResourceService resourceService)
focal_class.full_signature: public void setResourceService(ResourceService resourceService)
focal_class.identifier: setResourceService
focal_class.modifiers: public
focal_class.parameters: (ResourceService resourceService)
focal_class.return: void
focal_class.signature: void setResourceService(ResourceService resourceService)
focal_class.class_method_signature: RESTExtJsServiceImpl.setUserService(UserService userService)
focal_class.full_signature: public void setUserService(UserService userService)
focal_class.identifier: setUserService
focal_class.modifiers: public
focal_class.parameters: (UserService userService)
focal_class.return: void
focal_class.signature: void setUserService(UserService userService)
focal_class.class_method_signature: RESTExtJsServiceImpl.setUserGroupService(UserGroupService userGroupService)
focal_class.full_signature: public void setUserGroupService(UserGroupService userGroupService)
focal_class.identifier: setUserGroupService
focal_class.modifiers: public
focal_class.parameters: (UserGroupService userGroupService)
focal_class.return: void
focal_class.signature: void setUserGroupService(UserGroupService userGroupService)
focal_class.class_method_signature: RESTExtJsServiceImpl.getAllResources(SecurityContext sc, String nameLike,
              Integer start, Integer limit)
focal_class.full_signature: @Override public String getAllResources(SecurityContext sc, String nameLike,
              Integer start, Integer limit)
focal_class.identifier: getAllResources
focal_class.modifiers: @Override public
focal_class.parameters: (SecurityContext sc, String nameLike,
              Integer start, Integer limit)
focal_class.return: String
focal_class.signature: String getAllResources(SecurityContext sc, String nameLike,
              Integer start, Integer limit)
focal_class.class_method_signature: RESTExtJsServiceImpl.getResourcesByCategory(SecurityContext sc, String categoryName, Integer start,
              Integer limit, boolean includeAttributes,
              boolean includeData)
focal_class.full_signature: @Override public String getResourcesByCategory(SecurityContext sc, String categoryName, Integer start,
              Integer limit, boolean includeAttributes,
              boolean includeData)
focal_class.identifier: getResourcesByCategory
focal_class.modifiers: @Override public
focal_class.parameters: (SecurityContext sc, String categoryName, Integer start,
              Integer limit, boolean includeAttributes,
              boolean includeData)
focal_class.return: String
focal_class.signature: String getResourcesByCategory(SecurityContext sc, String categoryName, Integer start,
              Integer limit, boolean includeAttributes,
              boolean includeData)
focal_class.class_method_signature: RESTExtJsServiceImpl.getResourcesByCategory(SecurityContext sc, String categoryName, String resourceNameLike, Integer start,
              Integer limit, boolean includeAttributes, boolean includeData)
focal_class.full_signature: @Override public String getResourcesByCategory(SecurityContext sc, String categoryName, String resourceNameLike, Integer start,
              Integer limit, boolean includeAttributes, boolean includeData)
focal_class.identifier: getResourcesByCategory
focal_class.modifiers: @Override public
focal_class.parameters: (SecurityContext sc, String categoryName, String resourceNameLike, Integer start,
              Integer limit, boolean includeAttributes, boolean includeData)
focal_class.return: String
focal_class.signature: String getResourcesByCategory(SecurityContext sc, String categoryName, String resourceNameLike, Integer start,
              Integer limit, boolean includeAttributes, boolean includeData)
focal_class.class_method_signature: RESTExtJsServiceImpl.getResourcesByCategory(SecurityContext sc,
              String categoryName, String resourceNameLike, String extraAttributes,
              Integer start, Integer limit, boolean includeAttributes, boolean includeData)
focal_class.full_signature: @Override public String getResourcesByCategory(SecurityContext sc,
              String categoryName, String resourceNameLike, String extraAttributes,
              Integer start, Integer limit, boolean includeAttributes, boolean includeData)
focal_class.identifier: getResourcesByCategory
focal_class.modifiers: @Override public
focal_class.parameters: (SecurityContext sc,
              String categoryName, String resourceNameLike, String extraAttributes,
              Integer start, Integer limit, boolean includeAttributes, boolean includeData)
focal_class.return: String
focal_class.signature: String getResourcesByCategory(SecurityContext sc,
              String categoryName, String resourceNameLike, String extraAttributes,
              Integer start, Integer limit, boolean includeAttributes, boolean includeData)
focal_class.class_method_signature: RESTExtJsServiceImpl.getExtResourcesList(SecurityContext sc, Integer start, Integer limit,
              boolean includeAttributes, boolean includeData, SearchFilter filter)
focal_class.full_signature: @Override public ExtResourceList getExtResourcesList(SecurityContext sc, Integer start, Integer limit,
              boolean includeAttributes, boolean includeData, SearchFilter filter)
focal_class.identifier: getExtResourcesList
focal_class.modifiers: @Override public
focal_class.parameters: (SecurityContext sc, Integer start, Integer limit,
              boolean includeAttributes, boolean includeData, SearchFilter filter)
focal_class.return: ExtResourceList
focal_class.signature: ExtResourceList getExtResourcesList(SecurityContext sc, Integer start, Integer limit,
              boolean includeAttributes, boolean includeData, SearchFilter filter)
focal_class.class_method_signature: RESTExtJsServiceImpl.makeExtendedJSONResult(boolean success, long count, List<Resource> resources,
              User authUser, List<String> extraAttributes, boolean includeAttributes, boolean includeData)
focal_class.full_signature: private JSONObject makeExtendedJSONResult(boolean success, long count, List<Resource> resources,
              User authUser, List<String> extraAttributes, boolean includeAttributes, boolean includeData)
focal_class.identifier: makeExtendedJSONResult
focal_class.modifiers: private
focal_class.parameters: (boolean success, long count, List<Resource> resources,
              User authUser, List<String> extraAttributes, boolean includeAttributes, boolean includeData)
focal_class.return: JSONObject
focal_class.signature: JSONObject makeExtendedJSONResult(boolean success, long count, List<Resource> resources,
              User authUser, List<String> extraAttributes, boolean includeAttributes, boolean includeData)
focal_class.class_method_signature: RESTExtJsServiceImpl.makeJSONResult(boolean success, long count, List<ShortResource> resources,
              User authUser)
focal_class.full_signature: private JSONObject makeJSONResult(boolean success, long count, List<ShortResource> resources,
              User authUser)
focal_class.identifier: makeJSONResult
focal_class.modifiers: private
focal_class.parameters: (boolean success, long count, List<ShortResource> resources,
              User authUser)
focal_class.return: JSONObject
focal_class.signature: JSONObject makeJSONResult(boolean success, long count, List<ShortResource> resources,
              User authUser)
focal_class.class_method_signature: RESTExtJsServiceImpl.getUsersList(SecurityContext sc, String nameLike, Integer start,
              Integer limit, boolean includeAttributes)
focal_class.full_signature: @Override public ExtUserList getUsersList(SecurityContext sc, String nameLike, Integer start,
              Integer limit, boolean includeAttributes)
focal_class.identifier: getUsersList
focal_class.modifiers: @Override public
focal_class.parameters: (SecurityContext sc, String nameLike, Integer start,
              Integer limit, boolean includeAttributes)
focal_class.return: ExtUserList
focal_class.signature: ExtUserList getUsersList(SecurityContext sc, String nameLike, Integer start,
              Integer limit, boolean includeAttributes)
focal_class.class_method_signature: RESTExtJsServiceImpl.getGroupsList(SecurityContext sc, String nameLike, Integer start,
              Integer limit, boolean all)
focal_class.full_signature: @Override public ExtGroupList getGroupsList(SecurityContext sc, String nameLike, Integer start,
              Integer limit, boolean all)
focal_class.identifier: getGroupsList
focal_class.modifiers: @Override public
focal_class.parameters: (SecurityContext sc, String nameLike, Integer start,
              Integer limit, boolean all)
focal_class.return: ExtGroupList
focal_class.signature: ExtGroupList getGroupsList(SecurityContext sc, String nameLike, Integer start,
              Integer limit, boolean all)
focal_class.class_method_signature: RESTExtJsServiceImpl.getSecurityService()
focal_class.full_signature: @Override protected SecurityService getSecurityService()
focal_class.identifier: getSecurityService
focal_class.modifiers: @Override protected
focal_class.parameters: ()
focal_class.return: SecurityService
focal_class.signature: SecurityService getSecurityService()
focal_class.class_method_signature: RESTExtJsServiceImpl.makeGeneralizedJSONResult(boolean success, long count, List<?> resources,
              User authUser, List<String> extraAttributes, boolean includeAttributes, boolean includeData)
focal_class.full_signature: private JSONObject makeGeneralizedJSONResult(boolean success, long count, List<?> resources,
              User authUser, List<String> extraAttributes, boolean includeAttributes, boolean includeData)
focal_class.identifier: makeGeneralizedJSONResult
focal_class.modifiers: private
focal_class.parameters: (boolean success, long count, List<?> resources,
              User authUser, List<String> extraAttributes, boolean includeAttributes, boolean includeData)
focal_class.return: JSONObject
focal_class.signature: JSONObject makeGeneralizedJSONResult(boolean success, long count, List<?> resources,
              User authUser, List<String> extraAttributes, boolean includeAttributes, boolean includeData)
focal_class.class_method_signature: RESTExtJsServiceImpl.getResource(SecurityContext sc, long id)
focal_class.full_signature: @Override public ShortResource getResource(SecurityContext sc, long id)
focal_class.identifier: getResource
focal_class.modifiers: @Override public
focal_class.parameters: (SecurityContext sc, long id)
focal_class.return: ShortResource
focal_class.signature: ShortResource getResource(SecurityContext sc, long id)
focal_class.superclass: extends RESTServiceImpl
focal_method.body: @Override
      public String getAllResources(SecurityContext sc, String nameLike,
              Integer start, Integer limit)
              throws BadRequestWebEx {
  
          if (start == null || limit == null) {
              throw new BadRequestWebEx("Request parameters are missing !");
          }
  
          if (LOGGER.isInfoEnabled()) {
              LOGGER.info("Retrieving paginated resource list (start="+start+" limit="+limit+")");
          }
  
          User authUser = null;
          try {
              authUser = extractAuthUser(sc);
          } catch (InternalErrorWebEx ie) {
              // serch without user information
              LOGGER.warn("Error in validating user (this action should probably be aborted)", ie); // why is this exception caught?
          }
  
          int page = start == 0 ? start : start / limit;
  
          try {
              nameLike = nameLike.replaceAll("[*]", "%");
              // TOOD: implement includeAttributes and includeData
  
              List<ShortResource> resources = resourceService.getList(nameLike, page, limit, authUser);
  
              long count = 0;
              if (resources != null && resources.size() > 0) {
                  count = resourceService.getCountByFilterAndUser(nameLike, authUser);
              }
  
              JSONObject result = makeJSONResult(true, count, resources, authUser);
              return result.toString();
  
          } catch (BadRequestServiceEx e) {
              LOGGER.warn(e.getMessage(), e);
  
              JSONObject obj = makeJSONResult(false, 0, null, authUser);
              return obj.toString();
          }
      }
focal_method.class_method_signature: RESTExtJsServiceImpl.getAllResources(SecurityContext sc, String nameLike,
              Integer start, Integer limit)
focal_method.full_signature: @Override public String getAllResources(SecurityContext sc, String nameLike,
              Integer start, Integer limit)
focal_method.identifier: getAllResources
focal_method.invocations: isInfoEnabled info extractAuthUser warn replaceAll getList size getCountByFilterAndUser makeJSONResult toString warn getMessage makeJSONResult toString
focal_method.modifiers: @Override public
focal_method.parameters: (SecurityContext sc, String nameLike,
              Integer start, Integer limit)
focal_method.return: String
focal_method.signature: String getAllResources(SecurityContext sc, String nameLike,
              Integer start, Integer limit)