<commit_before>package cc.notsoclever.tools;

import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.codehaus.jackson.map.ObjectMapper;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class MyRouteBuilder extends RouteBuilder {

   public void configure() {

      from("restlet:///tags/{orgName}/{projectName}?restletMethods=get")
            .to("log:bar")
            .process(new Processor() {
                @Override
                public void process(Exchange exchange) throws Exception {
                    String on = exchange.getIn().getHeader("orgName", String.class);
                    String cn = exchange.getIn().getHeader("projectName", String.class);
                    Versions versions = new Versions(on, cn);
                    ObjectMapper mapper = new ObjectMapper();
                    String tags = versions.getTags();
                    String json = mapper.writeValueAsString(VersionsUtils.extractVersions(tags, cn));
                    exchange.getOut().setBody(json);
                    exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "application/json");
                }
            });

      from("restlet:///compare/{orgName}/{projectName}/{v1}/{v2}?restletMethods=get")
            .process(new Processor() {
               @Override
               public void process(Exchange exchange) throws Exception {
                  String on = exchange.getIn().getHeader("orgName", String.class);
                  String cn = exchange.getIn().getHeader("projectName", String.class);
                  String v1 = exchange.getIn().getHeader("v1", String.class);
                  String v2 = exchange.getIn().getHeader("v2", String.class);

                  Versions versions = new Versions(on, cn);
                  versions.compare(v1, v2);

                  ObjectMapper mapper = new ObjectMapper();

                  exchange.getOut().setBody(mapper.writeValueAsString(versions));
                  exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "application/json");
               }
            });

       from("restlet:///foo/{orgName}/{projectName}?restletMethods=get")
             .to("log:foo")
             .process(new Processor() {
                 @Override
                 public void process(Exchange exchange) throws Exception {

                     Path currentRelativePath = Paths.get("");
                     String s = currentRelativePath.toAbsolutePath().toString();
                     System.out.println("Current relative path is: " + s);
                     System.out.println(System.getProperty("user.dir"));

                     File folder = new File(System.getProperty("user.dir"));
                     File[] listOfFiles = folder.listFiles();

                     for (int i = 0; i < listOfFiles.length; i++) {
                         if (listOfFiles[i].isFile()) {
                             s = s + "File " + listOfFiles[i].getName();
                         } else if (listOfFiles[i].isDirectory()) {
                             s = s + "Directory " + listOfFiles[i].getName();
                         }
                     }

                     Message out = exchange.getOut();

                     out.setBody(s);
                     /*
                     InputStream input = getClass().getClassLoader().getResourceAsStream("index.html");
                     BufferedReader reader = new BufferedReader(new InputStreamReader(input));

                     StringBuffer sb = new StringBuffer();
                     //String s;
                     while ((s = reader.readLine()) != null) {
                         sb.append(s);
                     }
                     out.setBody(sb.toString());
                     */<commit_msg>testing real paths for loading<commit_after>package cc.notsoclever.tools;

import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;
import org.apache.camel.builder.RouteBuilder;
import org.codehaus.jackson.map.ObjectMapper;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

public class MyRouteBuilder extends RouteBuilder {

   public void configure() {

      from("restlet:///tags/{orgName}/{projectName}?restletMethods=get")
            .to("log:bar")
            .process(new Processor() {
                @Override
                public void process(Exchange exchange) throws Exception {
                    String on = exchange.getIn().getHeader("orgName", String.class);
                    String cn = exchange.getIn().getHeader("projectName", String.class);
                    Versions versions = new Versions(on, cn);
                    ObjectMapper mapper = new ObjectMapper();
                    String tags = versions.getTags();
                    String json = mapper.writeValueAsString(VersionsUtils.extractVersions(tags, cn));
                    exchange.getOut().setBody(json);
                    exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "application/json");
                }
            });

      from("restlet:///compare/{orgName}/{projectName}/{v1}/{v2}?restletMethods=get")
            .process(new Processor() {
               @Override
               public void process(Exchange exchange) throws Exception {
                  String on = exchange.getIn().getHeader("orgName", String.class);
                  String cn = exchange.getIn().getHeader("projectName", String.class);
                  String v1 = exchange.getIn().getHeader("v1", String.class);
                  String v2 = exchange.getIn().getHeader("v2", String.class);

                  Versions versions = new Versions(on, cn);
                  versions.compare(v1, v2);

                  ObjectMapper mapper = new ObjectMapper();

                  exchange.getOut().setBody(mapper.writeValueAsString(versions));
                  exchange.getOut().setHeader(Exchange.CONTENT_TYPE, "application/json");
               }
            });

       from("restlet:///foo/{orgName}/{projectName}?restletMethods=get")
             .to("log:foo")
             .process(new Processor() {
                 @Override
                 public void process(Exchange exchange) throws Exception {

                     Path currentRelativePath = Paths.get("");
                     String s = currentRelativePath.toAbsolutePath().toString();
                     System.out.println("Current relative path is: " + s);
                     System.out.println(System.getProperty("user.dir"));

                     File folder = new File(System.getProperty("user.dir" + "/target"));
                     File[] listOfFiles = folder.listFiles();

                     for (int i = 0; i < listOfFiles.length; i++) {
                         if (listOfFiles[i].isFile()) {
                             s = s + "File " + listOfFiles[i].getName();
                         } else if (listOfFiles[i].isDirectory()) {
                             s = s + "Directory " + listOfFiles[i].getName();
                         }
                     }

                     Message out = exchange.getOut();

                     out.setBody(s);
                     /*
                     InputStream input = getClass().getClassLoader().getResourceAsStream("index.html");
                     BufferedReader reader = new BufferedReader(new InputStreamReader(input));

                     StringBuffer sb = new StringBuffer();
                     //String s;
                     while ((s = reader.readLine()) != null) {
                         sb.append(s);
                     }
                     out.setBody(sb.toString());
                     */
{'fraction_non_alphanumeric': 0.11787771106482049, 'fraction_numerical': 0.0022056120573459136, 'mean_word_length': 1.7080291970802919, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1787135', 'n_tokens_mistral': 2083, 'n_tokens_neox': 1954, 'n_words': 385}