/**
   * This method is used to get a details difference of two resource while considering the media
   * type.
   *
   * @param resourcePathOne resource path one
   * @param resourcePathTwo resource path two
   * @param mediaType media type
   * @return Comparison object which includes the difference parameters.
   * @throws ComparisonException
   * @throws WSDLException
   * @throws RegistryException
   * @throws UnsupportedEncodingException
   */
  public Comparison getArtifactDetailDiff(
      String resourcePathOne, String resourcePathTwo, String mediaType)
      throws ComparisonException, WSDLException, RegistryException, UnsupportedEncodingException {

    String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    Registry registry =
        RegistryCoreServiceComponent.getRegistryService().getRegistry(username, tenantId);
    Resource resourceOne = registry.get(resourcePathOne);
    Resource resourceTwo = registry.get(resourcePathTwo);

    switch (mediaType) {
      case ComparatorConstants.WSDL_MEDIA_TYPE:
        return getWSDLComparison(resourceOne, resourceTwo);
      default:
        return null;
    }
  }
  /**
   * This method is used to get the text difference of two strings.
   *
   * @param resourcePathOne resource path one.
   * @param resourcePathTwo resource path two.
   * @return Comparison object which includes the difference parameters.
   * @throws ComparisonException
   * @throws WSDLException
   * @throws RegistryException
   * @throws UnsupportedEncodingException
   */
  public Comparison getArtifactTextDiff(String resourcePathOne, String resourcePathTwo)
      throws ComparisonException, WSDLException, RegistryException, UnsupportedEncodingException {

    String username = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    Registry registry =
        RegistryCoreServiceComponent.getRegistryService().getRegistry(username, tenantId);
    Resource resourceOne = registry.get(resourcePathOne);
    Resource resourceTwo = registry.get(resourcePathTwo);

    DiffGeneratorFactory factory = new TextDiffGeneratorFactory();
    DiffGenerator flow = factory.getDiffGenerator();

    String resourceOneText = new String((byte[]) resourceOne.getContent(), "UTF-8");
    String resourceTwoText = new String((byte[]) resourceTwo.getContent(), "UTF-8");

    String resourceOneFormattedText = prettyFormatText(resourceOneText, resourceOne.getMediaType());
    String resourceTwoFormattedText = prettyFormatText(resourceTwoText, resourceTwo.getMediaType());
    return flow.compare(
        resourceOneFormattedText,
        resourceTwoFormattedText,
        ComparatorConstants.TEXT_PLAIN_MEDIA_TYPE);
  }