Uploaded image for project: 'Stratos'
  1. Stratos
  2. STRATOS-969 Improvements in REST API
  3. STRATOS-966

Inconsistency in parameter definition in REST API coding

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 4.1.0 M4
    • 4.1.0 RC3
    • REST API
    • None

    Description

      When going through the code I noticed that there is inconsistency at times in the code. For example, in [1] and [2] tenantdomain and domain appear to be the same parameter, but it has been referred to by two names.

      [1]
      @DELETE
      @Path("/tenant/

      {tenantDomain}

      ")
      @Consumes("application/json")
      @Produces("application/json")
      @AuthorizationAction("/permission/protected/manage/monitor/tenants")
      @SuperTenantService(true)
      public Response deleteTenant(@PathParam("tenantDomain") String tenantDomain) throws RestAPIException {
      TenantManager tenantManager = ServiceHolder.getTenantManager();
      int tenantId = 0;
      try

      { tenantId = tenantManager.getTenantId(tenantDomain); }

      catch (org.wso2.carbon.user.api.UserStoreException e)

      { String msg = "Error in deleting tenant " + tenantDomain; log.error(msg, e); //throw new RestAPIException(msg); return Response.status(Response.Status.NOT_FOUND).build(); }

      try

      { //TODO: billing related info cleanup TenantMgtUtil.deleteTenantRegistryData(tenantId); TenantMgtUtil.deleteTenantUMData(tenantId); tenantManager.deleteTenant(tenantId); log.info("Deleted tenant with domain: " + tenantDomain + " and tenant id: " + tenantId + " from the system."); }

      catch (Exception e)

      { String msg = "Error deleting tenant with domain: " + tenantDomain + " and tenant id: " + tenantId + "."; log.error(msg, e); throw new RestAPIException(msg); }

      return Response.noContent().build();
      }

      [2]
      @GET
      @Path("tenant/search/

      {domain}

      ")
      @Consumes("application/json")
      @Produces("application/json")
      @AuthorizationAction("/permission/protected/manage/monitor/tenants")
      @SuperTenantService(true)
      public TenantInfoBean[] retrievePartialSearchTenants(@PathParam("domain") String domain) throws RestAPIException {
      List<TenantInfoBean> tenantList = null;
      try

      { tenantList = searchPartialTenantsDomains(domain); }

      catch (Exception e)

      { String msg = "Error in getting information for tenant " + domain; log.error(msg, e); throw new RestAPIException(msg); }

      return tenantList.toArray(new TenantInfoBean[tenantList.size()]);
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            mariangela Mariangela Hills
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: