<commit_before>package org.opens.tanaguru.entity.service.subject;

import java.util.List;
import org.opens.tanaguru.entity.subject.Page;
import org.opens.tanaguru.entity.subject.Site;
import org.opens.tanaguru.entity.subject.WebResource;
import org.opens.tanaguru.entity.factory.subject.WebResourceFactory;
import org.opens.tanaguru.entity.dao.subject.WebResourceDAO;
import com.adex.sdk.entity.service.AbstractGenericDataService;
import org.opens.tanaguru.entity.audit.ProcessResult;

/**
 * 
 * @author ADEX
 */
public class WebResourceDataServiceImpl extends AbstractGenericDataService<WebResource, Long> implements
        WebResourceDataService {

    private final String HTTP_PROTOCOL_PREFIX = "http://";
    private final String HTTPS_PROTOCOL_PREFIX = "https://";
    private final String FILE_PROTOCOL_PREFIX = "file://";
    private final String FILE_PREFIX = "/";
//    private final String windowsPathPattern = " ^([a-zA-Z]:) \\{1} | ((\\{1}) [^\\] ([^/:*?&lt;&gt;&quot;|]*(?&lt;![ ])))+)$" ;

    public WebResourceDataServiceImpl() {
        super();
    }

    @Override
    public Page createPage(String url) {
        return ((WebResourceFactory) entityFactory).createPage(addProtocolToUrl(url));
    }

    @Override
    public Site createSite(String url) {
        return ((WebResourceFactory) entityFactory).createSite(url);
    }

    @Override
    public WebResource getByUrl(String url) {
        return ((WebResourceDAO) entityDao).findByUrl(url);
    }

    @Override
    public WebResource read(Long key) {
        WebResource entity = super.read(key);
        return entity;
    }

    protected void deepLoad(ProcessResult processResult) {
        for (ProcessResult childResult : processResult.getChildResultList()) {
            deepLoad(childResult);
        }
    }

    /**
     * This method add the protocol to the url if the protocol is missing
     * @param url
     * @return
     */
    private String addProtocolToUrl(String url) {
        if (!url.startsWith(HTTP_PROTOCOL_PREFIX)
                && !url.startsWith(HTTPS_PROTOCOL_PREFIX)
                && !url.startsWith(FILE_PROTOCOL_PREFIX)) {

            if (url.startsWith(FILE_PREFIX)) {
                url = FILE_PROTOCOL_PREFIX + url;
            } else {
                url = HTTP_PROTOCOL_PREFIX + url;
            }
        }
        return url;
    }

    @Override
    public WebResource getByUrlAndParentWebResource(String url, WebResource webResource) {
        return ((WebResourceDAO) entityDao).findByUrlAndParentWebResource(url, webResource);
    }<commit_msg>Engine : WebResourceDataService implementation modification to use the FileNaming service when create an instance of Page<commit_after>package org.opens.tanaguru.entity.service.subject;

import java.util.List;
import org.opens.tanaguru.entity.subject.Page;
import org.opens.tanaguru.entity.subject.Site;
import org.opens.tanaguru.entity.subject.WebResource;
import org.opens.tanaguru.entity.factory.subject.WebResourceFactory;
import org.opens.tanaguru.entity.dao.subject.WebResourceDAO;
import com.adex.sdk.entity.service.AbstractGenericDataService;
import org.opens.tanaguru.entity.audit.ProcessResult;
import org.opens.tanaguru.util.FileNaming;

/**
 * 
 * @author ADEX
 */
public class WebResourceDataServiceImpl extends AbstractGenericDataService<WebResource, Long> implements
        WebResourceDataService {

    public WebResourceDataServiceImpl() {
        super();
    }

    @Override
    public Page createPage(String url) {
        return ((WebResourceFactory) entityFactory).createPage(FileNaming.addProtocolToUrl(url));
    }

    @Override
    public Site createSite(String url) {
        return ((WebResourceFactory) entityFactory).createSite(url);
    }

    @Override
    public WebResource getByUrl(String url) {
        return ((WebResourceDAO) entityDao).findByUrl(url);
    }

    @Override
    public WebResource read(Long key) {
        WebResource entity = super.read(key);
        return entity;
    }

    protected void deepLoad(ProcessResult processResult) {
        for (ProcessResult childResult : processResult.getChildResultList()) {
            deepLoad(childResult);
        }
    }

    @Override
    public WebResource getByUrlAndParentWebResource(String url, WebResource webResource) {
        return ((WebResourceDAO) entityDao).findByUrlAndParentWebResource(url, webResource);
    }
{'fraction_non_alphanumeric': 0.103887247101614, 'fraction_numerical': 0.0004546487838145033, 'mean_word_length': 3.408817635270541, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7492473', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1249, 'n_words': 248}