Source:
public Response subscriptionPoliciesGet(String xWSO2Tenant, String policyName, MessageContext messageContext) { SubscriptionValidationDAO subscriptionValidationDAO = new SubscriptionValidationDAO(); String validatedTenantDomain = InternalServiceDataUtil.validateTenantDomain(xWSO2Tenant); if (StringUtils.isNotEmpty(xWSO2Tenant)) { if (StringUtils.isNotEmpty(policyName)) { if (InternalServiceDataUtil.isUserAuthorizedToTenant(validatedTenantDomain)) { List<SubscriptionPolicy> model = new ArrayList<>(); SubscriptionPolicy subscriptionPolicy = subscriptionValidationDAO.getSubscriptionPolicyByNameForTenant( policyName, xWSO2Tenant); if (subscriptionPolicy != null) { model.add(subscriptionPolicy); } return Response.ok().entity(InternalServiceDataUtil. fromSubscriptionPolicyToSubscriptionPolicyListDTO(model)).build(); } } else { if (InternalServiceDataUtil.isUserAuthorizedToTenant(validatedTenantDomain)) { return Response.ok().entity(InternalServiceDataUtil. fromSubscriptionPolicyToSubscriptionPolicyListDTO(subscriptionValidationDAO. getAllSubscriptionPolicies(validatedTenantDomain))).build(); } } } else { if (StringUtils.isNotEmpty(policyName)) { return Response.status(Response.Status.BAD_REQUEST.getStatusCode(), "X-WSo2-Tenant header is missing.").build(); } else { if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equalsIgnoreCase(validatedTenantDomain) && InternalServiceDataUtil.isUserAuthorizedToTenant(validatedTenantDomain)) { return Response.ok().entity(InternalServiceDataUtil. fromSubscriptionPolicyToSubscriptionPolicyListDTO(subscriptionValidationDAO. getAllSubscriptionPolicies())).build(); } else { InternalServiceDataUtil.handleUnauthorizedError(); } } } return null; }

Target:
public Response subscriptionPoliciesGet(String xWSO2Tenant, String policyName, MessageContext messageContext) { SubscriptionValidationDAO subscriptionValidationDAO = new SubscriptionValidationDAO(); String validatedTenantDomain = InternalServiceDataUtil.validateTenantDomain(xWSO2Tenant); if (StringUtils.isNotEmpty(xWSO2Tenant)) { if (StringUtils.isNotEmpty(policyName)) { if (InternalServiceDataUtil.isUserAuthorizedToTenant(validatedTenantDomain)) { List<SubscriptionPolicy> model = new ArrayList<>(); SubscriptionPolicy subscriptionPolicy = subscriptionValidationDAO.getSubscriptionPolicyByNameForTenant( policyName, xWSO2Tenant); if (subscriptionPolicy != null) { model.add(subscriptionPolicy); } return Response.ok().entity(InternalServiceDataUtil. fromSubscriptionPolicyToSubscriptionPolicyListDTO(model)).build(); } } else { if (InternalServiceDataUtil.isUserAuthorizedToTenant(validatedTenantDomain)) { return Response.ok().entity(InternalServiceDataUtil. fromSubscriptionPolicyToSubscriptionPolicyListDTO(subscriptionValidationDAO. getAllSubscriptionPolicies(validatedTenantDomain))).build(); } } } else { if (StringUtils.isNotEmpty(policyName)) { return Response.status(Response.Status.BAD_REQUEST.getStatusCode(), "X-WSO2-Tenant header is missing.").build(); } else { if (MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equalsIgnoreCase(validatedTenantDomain) && InternalServiceDataUtil.isUserAuthorizedToTenant(validatedTenantDomain)) { return Response.ok().entity(InternalServiceDataUtil. fromSubscriptionPolicyToSubscriptionPolicyListDTO(subscriptionValidationDAO. getAllSubscriptionPolicies())).build(); } else { InternalServiceDataUtil.handleUnauthorizedError(); } } } return null; }