/**
   * This method is used to get wsdl difference comparison.
   *
   * @param WSDLOne wsdl one.
   * @param WSDLTwo wsdl two.
   * @return Comparison object which includes the difference parameters.
   * @throws ComparisonException
   * @throws WSDLException
   * @throws RegistryException
   * @throws UnsupportedEncodingException
   */
  private Comparison getWSDLComparison(Resource WSDLOne, Resource WSDLTwo)
      throws ComparisonException, WSDLException, RegistryException, UnsupportedEncodingException {
    GovernanceDiffGeneratorFactory diffGeneratorFactory = new GovernanceDiffGeneratorFactory();
    DiffGenerator flow = diffGeneratorFactory.getDiffGenerator();
    WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();

    InputSource inputSourceOne =
        new InputSource(new ByteArrayInputStream((byte[]) WSDLOne.getContent()));
    Definition originalWSDL = wsdlReader.readWSDL(null, inputSourceOne);

    InputSource inputSourceTwo =
        new InputSource(new ByteArrayInputStream((byte[]) WSDLTwo.getContent()));
    Definition changedWSDL = wsdlReader.readWSDL(null, inputSourceTwo);

    return flow.compare(originalWSDL, changedWSDL, ComparatorConstants.WSDL_MEDIA_TYPE);
  }
  /**
   * 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);
  }