Search in sources :

Example 16 with Page

use of org.asqatasun.entity.subject.Page in project Asqatasun by Asqatasun.

the class PageListController method pageLinkDispatcher.

/**
     * This method dispatches the result depending on the parameters passed to
     * the request. Only multi-pages audit are considered here.
     *
     * @param request
     * @param webResource
     * @param model
     * @return
     * @throws Exception
     */
private String pageLinkDispatcher(HttpServletRequest request, Audit audit, Model model) throws Exception {
    if (audit.getSubject() instanceof Page) {
        throw new ForbiddenPageException();
    }
    String status = ServletRequestUtils.getStringParameter(request, TgolKeyStore.STATUS_KEY);
    HttpStatusCodeFamily httpStatusCode = getHttpStatusCodeFamily(status);
    // the repartion of the pages regarding the httpStatusCode
    if (httpStatusCode == null) {
        if (!isAuthorizedScopeForPageList(audit)) {
            throw new ForbiddenScopeException();
        }
        try {
            Contract currentContract = retrieveContractFromAudit(audit);
            model.addAttribute(TgolKeyStore.CONTRACT_NAME_KEY, currentContract.getLabel());
            model.addAttribute(TgolKeyStore.CONTRACT_ID_KEY, currentContract.getId());
            String testLabel = ServletRequestUtils.getStringParameter(request, TgolKeyStore.TEST_KEY);
            if (StringUtils.isNotBlank(testLabel)) {
                model.addAttribute(TgolKeyStore.TEST_CODE_KEY, getTestDataService().getTestFromAuditAndLabel(audit, testLabel));
            }
            return this.preparePageListData(audit, model);
        } catch (ServletRequestBindingException e) {
            return TgolKeyStore.OUPS_VIEW_REDIRECT_NAME;
        }
    } else {
        boolean isAuthorizedScopeForPageList = isAuthorizedScopeForPageList(audit);
        Contract currentContract = retrieveContractFromAudit(audit);
        model.addAttribute(TgolKeyStore.CONTRACT_NAME_KEY, currentContract.getLabel());
        model.addAttribute(TgolKeyStore.CONTRACT_ID_KEY, currentContract.getId());
        // used in the jsp
        if (!isAuthorizedScopeForPageList) {
            model.addAttribute(TgolKeyStore.AUDIT_NUMBER_KEY, true);
        }
        String testLabel = ServletRequestUtils.getStringParameter(request, TgolKeyStore.TEST_KEY);
        if (StringUtils.isNotBlank(testLabel)) {
            model.addAttribute(TgolKeyStore.TEST_CODE_KEY, getTestDataService().getTestFromAuditAndLabel(audit, testLabel));
        }
        return this.preparePageListStatsByHttpStatusCode(audit, model, httpStatusCode, request, false);
    }
}
Also used : ServletRequestBindingException(org.springframework.web.bind.ServletRequestBindingException) HttpStatusCodeFamily(org.asqatasun.webapp.util.HttpStatusCodeFamily) Page(org.asqatasun.entity.subject.Page) ForbiddenScopeException(org.asqatasun.webapp.exception.ForbiddenScopeException) Contract(org.asqatasun.webapp.entity.contract.Contract) ForbiddenPageException(org.asqatasun.webapp.exception.ForbiddenPageException)

Example 17 with Page

use of org.asqatasun.entity.subject.Page in project Asqatasun by Asqatasun.

the class ContentLoaderImpl method run.

private List<Content> run(WebResource webResource) {
    // TODO Handle exceptions like 404, 403, 500, ...
    List<Content> localResult = new ArrayList<>();
    if (webResource instanceof Page) {
        downloader.setURL(webResource.getURL());
        downloader.run();
        String stringContent = downloader.getResult();
        Content content = contentDataService.getSSP(dateFactory.createDate(), webResource.getURL(), stringContent, (Page) webResource, HTTP_CODE_OK);
        localResult.add(content);
    }
    if (webResource instanceof Site) {
        Site site = (Site) webResource;
        for (WebResource component : site.getComponentList()) {
            localResult.addAll(run(component));
        }
    }
    return localResult;
}
Also used : Site(org.asqatasun.entity.subject.Site) Content(org.asqatasun.entity.audit.Content) ArrayList(java.util.ArrayList) WebResource(org.asqatasun.entity.subject.WebResource) Page(org.asqatasun.entity.subject.Page)

Example 18 with Page

use of org.asqatasun.entity.subject.Page in project Asqatasun by Asqatasun.

the class FileContentLoaderImpl method run.

/**
     * 
     * @param webResource
     * @return 
     */
private List<Content> run(WebResource webResource) {
    List<Content> localResult = new ArrayList<>();
    if (webResource instanceof Page) {
        Content content = contentDataService.getSSP(dateFactory.createDate(), webResource.getURL(), fileMap.get(FileNaming.removeFilePrefix(webResource.getURL())), (Page) webResource, HttpStatus.SC_OK);
        localResult.add(content);
    } else if (webResource instanceof Site) {
        Site site = (Site) webResource;
        for (WebResource component : site.getComponentList()) {
            localResult.addAll(run(component));
        }
    }
    return localResult;
}
Also used : Site(org.asqatasun.entity.subject.Site) Content(org.asqatasun.entity.audit.Content) ArrayList(java.util.ArrayList) WebResource(org.asqatasun.entity.subject.WebResource) Page(org.asqatasun.entity.subject.Page)

Example 19 with Page

use of org.asqatasun.entity.subject.Page in project Asqatasun by Asqatasun.

the class Aw22Rule11032Test method setUpWebResourceMap.

@Override
protected void setUpWebResourceMap() {
    getWebResourceMap().put("AW22.Test.11.3.2-4NA-01", getWebResourceFactory().createPage(getTestcasesFilePath() + "accessiweb22/Aw22Rule11032/AW22.Test.11.3.2-3NMI-01.html"));
    Site site = getWebResourceFactory().createSite("file:Site-NotTested");
    getWebResourceMap().put("AW22.Test.11.3.2-5NT-01", site);
    Page page = getWebResourceFactory().createPage(getTestcasesFilePath() + "accessiweb22/Aw22Rule11032/AW22.Test.11.3.2-3NMI-01.html");
    site.addChild(page);
    getWebResourceMap().put("AW22.Test.11.3.2-5NT-01-page1", page);
    page = getWebResourceFactory().createPage(getTestcasesFilePath() + "accessiweb22/Aw22Rule11032/AW22.Test.11.3.2-3NMI-01.html");
    site.addChild(page);
    getWebResourceMap().put("AW22.Test.11.3.2-5NT-01-page1", page);
}
Also used : Site(org.asqatasun.entity.subject.Site) Page(org.asqatasun.entity.subject.Page)

Example 20 with Page

use of org.asqatasun.entity.subject.Page in project Asqatasun by Asqatasun.

the class Aw22Rule12051Test method setUpWebResourceMap.

@Override
protected void setUpWebResourceMap() {
    getWebResourceMap().put("AW22.Test.12.5.1-4NA-01", getWebResourceFactory().createPage(getTestcasesFilePath() + "accessiweb22/Aw22Rule12051/AW22.Test.12.5.1-3NMI-01.html"));
    Site site = getWebResourceFactory().createSite("file:Site-NotTested");
    getWebResourceMap().put("AW22.Test.12.5.1-5NT-01", site);
    Page page = getWebResourceFactory().createPage(getTestcasesFilePath() + "accessiweb22/Aw22Rule12051/AW22.Test.12.5.1-3NMI-01.html");
    site.addChild(page);
    getWebResourceMap().put("AW22.Test.12.5.1-5NT-01-page1", page);
    page = getWebResourceFactory().createPage(getTestcasesFilePath() + "accessiweb22/Aw22Rule12051/AW22.Test.12.5.1-3NMI-01.html");
    site.addChild(page);
    getWebResourceMap().put("AW22.Test.12.5.1-5NT-01-page1", page);
}
Also used : Site(org.asqatasun.entity.subject.Site) Page(org.asqatasun.entity.subject.Page)

Aggregations

Page (org.asqatasun.entity.subject.Page)77 Site (org.asqatasun.entity.subject.Site)68 WebResource (org.asqatasun.entity.subject.WebResource)7 ArrayList (java.util.ArrayList)6 Query (javax.persistence.Query)6 Audit (org.asqatasun.entity.audit.Audit)4 ProcessResult (org.asqatasun.entity.audit.ProcessResult)4 List (java.util.List)3 Map (java.util.Map)3 SSP (org.asqatasun.entity.audit.SSP)3 Content (org.asqatasun.entity.audit.Content)2 DefiniteResult (org.asqatasun.entity.audit.DefiniteResult)2 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)2 ColumnBuilderException (ar.com.fdvs.dj.domain.builders.ColumnBuilderException)1 IOException (java.io.IOException)1 JRException (net.sf.jasperreports.engine.JRException)1 PreProcessResult (org.asqatasun.entity.audit.PreProcessResult)1 Scope (org.asqatasun.entity.reference.Scope)1 ContentDataService (org.asqatasun.entity.service.audit.ContentDataService)1 WebResourceDataService (org.asqatasun.entity.service.subject.WebResourceDataService)1