Search in sources :

Example 21 with Audit

use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.

the class ScenarioLoaderServiceImpl method loadScenario.

@Override
public List<Content> loadScenario(WebResource webResource, String scenarioFile) {
    Audit audit = webResource.getAudit();
    ScenarioLoader scenarioLoader = scenarioLoaderFactory.create(webResource, scenarioFile);
    scenarioLoader.run();
    List<Content> contentList = scenarioLoader.getResult();
    for (Content content : contentList) {
        //            content.setAudit(audit);
        contentDataService.saveAuditToContent(content.getId(), audit.getId());
    }
    // Before returning the list of content we save the webResource
    webResourceDataService.saveOrUpdate(webResource);
    return contentList;
}
Also used : Audit(org.asqatasun.entity.audit.Audit) ScenarioLoader(org.asqatasun.scenarioloader.ScenarioLoader) Content(org.asqatasun.entity.audit.Content)

Example 22 with Audit

use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.

the class AuditLauncherController method preparePageAudit.

/**
     * This methods controls the validity of the form and launch an audit with
     * values populated by the user. In case of audit failure, an appropriate
     * message is displayed
     *
     * @param pageAuditSetUpCommand
     * @param contract
     * @param locale
     * @param auditScope
     * @param model
     * @return
     */
private String preparePageAudit(final AuditSetUpCommand auditSetUpCommand, final Contract contract, final Locale locale, final ScopeEnum auditScope, Model model) {
    Audit audit;
    boolean isPageAudit = true;
    // if the form is correct, we launch the audit
    try {
        if (auditScope.equals(ScopeEnum.FILE)) {
            audit = launchUploadAudit(contract, auditSetUpCommand, locale);
            isPageAudit = false;
        } else {
            audit = launchPageAudit(contract, auditSetUpCommand, locale);
        }
    } catch (KrashAuditException kae) {
        return TgolKeyStore.OUPS_VIEW_NAME;
    }
    // page and send an email when it's ready
    if (audit == null) {
        model.addAttribute(TgolKeyStore.TESTED_URL_KEY, auditSetUpCommand.getUrlList().get(0));
        model.addAttribute(TgolKeyStore.CONTRACT_ID_KEY, contract.getId());
        model.addAttribute(TgolKeyStore.CONTRACT_NAME_KEY, contract.getLabel());
        model.addAttribute(TgolKeyStore.IS_PAGE_AUDIT_KEY, isPageAudit);
        if (!getEmailSentToUserExclusionList().contains(contract.getUser().getEmail1())) {
            model.addAttribute(TgolKeyStore.IS_USER_NOTIFIED_KEY, true);
        }
        return TgolKeyStore.GREEDY_AUDIT_VIEW_NAME;
    }
    if (audit.getStatus() != AuditStatus.COMPLETED) {
        return prepareFailedAuditData(audit, model);
    }
    if (audit.getSubject() instanceof Site) {
        // in case of group of page, we display the list of audited pages
        model.addAttribute(TgolKeyStore.AUDIT_ID_KEY, audit.getId());
        model.addAttribute(TgolKeyStore.STATUS_KEY, HttpStatusCodeFamily.f2xx);
        return TgolKeyStore.PAGE_LIST_XXX_VIEW_REDIRECT_NAME;
    } else if (audit.getSubject() instanceof Page) {
        model.addAttribute(TgolKeyStore.WEBRESOURCE_ID_KEY, audit.getSubject().getId());
        return TgolKeyStore.RESULT_PAGE_VIEW_REDIRECT_NAME;
    }
    throw new LostInSpaceException(getCurrentUser());
}
Also used : Site(org.asqatasun.entity.subject.Site) Audit(org.asqatasun.entity.audit.Audit) KrashAuditException(org.asqatasun.webapp.exception.KrashAuditException) LostInSpaceException(org.asqatasun.webapp.exception.LostInSpaceException) Page(org.asqatasun.entity.subject.Page)

Example 23 with Audit

use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.

the class AuditSynthesisController method displayAuditTestSynthesisFromContract.

/**
     *
     * @param auditId
     * @param request
     * @param response
     * @param model
     * @return
     */
@RequestMapping(value = TgolKeyStore.FAILED_TEST_LIST_CONTRACT_URL, method = RequestMethod.GET)
@Secured({ TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY })
public String displayAuditTestSynthesisFromContract(@RequestParam(TgolKeyStore.AUDIT_ID_KEY) String auditId, HttpServletRequest request, HttpServletResponse response, Model model) {
    Long aId;
    try {
        aId = Long.valueOf(auditId);
    } catch (NumberFormatException nfe) {
        throw new ForbiddenPageException();
    }
    Audit audit = getAuditDataService().read(aId);
    if (isUserAllowedToDisplayResult(audit)) {
        if (isAuthorizedScopeForSynthesis(audit)) {
            Contract contract = retrieveContractFromAudit(audit);
            model.addAttribute(TgolKeyStore.CONTRACT_ID_KEY, contract.getId());
            model.addAttribute(TgolKeyStore.CONTRACT_NAME_KEY, contract.getLabel());
            model.addAttribute(TgolKeyStore.AUDIT_ID_KEY, auditId);
            model.addAttribute(TgolKeyStore.REFERENTIAL_CD_KEY, getParameterDataService().getReferentialKeyFromAudit(audit));
            model.addAttribute(TgolKeyStore.WEBRESOURCE_ID_KEY, audit.getSubject().getId());
            Site site = (Site) audit.getSubject();
            //TODO cas manual
            addAuditStatisticsToModel(site, model, TgolKeyStore.TEST_DISPLAY_SCOPE_VALUE);
            model.addAttribute(TgolKeyStore.FAILED_TEST_INFO_BY_OCCURRENCE_SET_KEY, getStatisticsDataService().getFailedTestByOccurrence(site, audit, -1));
            model.addAttribute(TgolKeyStore.HAS_SITE_SCOPE_TEST_KEY, processResultDataService.hasAuditSiteScopeResult(site, getSiteScope()));
            model.addAttribute(TgolKeyStore.STATUS_KEY, computeAuditStatus(site.getAudit()));
            return TgolKeyStore.FAILED_TEST_LIST_VIEW_NAME;
        } else {
            throw new ForbiddenPageException();
        }
    } else {
        throw new ForbiddenUserException();
    }
}
Also used : Site(org.asqatasun.entity.subject.Site) Audit(org.asqatasun.entity.audit.Audit) Contract(org.asqatasun.webapp.entity.contract.Contract) ForbiddenUserException(org.asqatasun.webapp.exception.ForbiddenUserException) ForbiddenPageException(org.asqatasun.webapp.exception.ForbiddenPageException) Secured(org.springframework.security.access.annotation.Secured) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 24 with Audit

use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.

the class AuditResultController method displaySourceCodeFromContract.

/**
     *
     * @param webresourceId
     * @param request
     * @param response
     * @param model
     * @return
     */
@RequestMapping(value = TgolKeyStore.SOURCE_CODE_CONTRACT_URL, method = RequestMethod.GET)
@Secured({ TgolKeyStore.ROLE_USER_KEY, TgolKeyStore.ROLE_ADMIN_KEY })
public String displaySourceCodeFromContract(@RequestParam(TgolKeyStore.WEBRESOURCE_ID_KEY) String webresourceId, HttpServletRequest request, HttpServletResponse response, Model model) {
    WebResource webResource;
    try {
        webResource = getWebResourceDataService().ligthRead(Long.valueOf(webresourceId));
    } catch (NumberFormatException nfe) {
        throw new ForbiddenPageException();
    }
    if (webResource instanceof Site) {
        throw new ForbiddenPageException();
    }
    Audit audit = getAuditFromWebResource(webResource);
    if (isUserAllowedToDisplayResult(audit)) {
        Page page = (Page) webResource;
        SSP ssp = getContentDataService().findSSP(page, page.getURL());
        model.addAttribute(TgolKeyStore.SOURCE_CODE_KEY, highlightSourceCode(ssp));
        ScopeEnum scope = getActDataService().getActFromAudit(audit).getScope().getCode();
        if (scope.equals(ScopeEnum.GROUPOFPAGES) || scope.equals(ScopeEnum.PAGE)) {
            model.addAttribute(TgolKeyStore.IS_GENERATED_HTML_KEY, true);
        }
        return TgolKeyStore.SOURCE_CODE_PAGE_VIEW_NAME;
    } else {
        throw new ForbiddenUserException(getCurrentUser());
    }
}
Also used : Site(org.asqatasun.entity.subject.Site) Audit(org.asqatasun.entity.audit.Audit) SSP(org.asqatasun.entity.audit.SSP) ScopeEnum(org.asqatasun.webapp.entity.contract.ScopeEnum) WebResource(org.asqatasun.entity.subject.WebResource) Page(org.asqatasun.entity.subject.Page) ForbiddenUserException(org.asqatasun.webapp.exception.ForbiddenUserException) ForbiddenPageException(org.asqatasun.webapp.exception.ForbiddenPageException) Secured(org.springframework.security.access.annotation.Secured) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 25 with Audit

use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.

the class AbstractAuditResultController method dispatchDisplayResultRequest.

/**
     * Regarding the page type, this method collects data, set them up and
     * display the appropriate result page.
     *
     * @param webResourceId
     * @param auditResultSortCommand
     * @param model
     * @param request
     * @param isManualAudit
     * @param manualAuditCommand
     * @return
     */
protected String dispatchDisplayResultRequest(Long webResourceId, AuditResultSortCommand auditResultSortCommand, Model model, HttpServletRequest request, boolean isManualAudit, ManualAuditCommand manualAuditCommand) {
    // We first check that the current user is allowed to display the result
    // of this audit
    WebResource webResource = getWebResourceDataService().ligthRead(webResourceId);
    if (webResource == null) {
        throw new ForbiddenPageException();
    }
    Audit audit = getAuditFromWebResource(webResource);
    // data are retrieved to be prepared and displayed
    if (isUserAllowedToDisplayResult(audit)) {
        this.callGc(webResource);
        String displayScope = computeDisplayScope(request, auditResultSortCommand);
        addAuditStatisticsToModel(webResource, model, displayScope);
        // The page is displayed with sort option. Form needs to be set up
        prepareDataForSortConsole(webResourceId, displayScope, auditResultSortCommand, model, isManualAudit);
        // Data need to be prepared regarding the audit type
        return prepareSuccessfullAuditData(webResource, audit, model, displayScope, getLocaleResolver().resolveLocale(request), isManualAudit, manualAuditCommand);
    } else {
        throw new ForbiddenUserException(getCurrentUser());
    }
}
Also used : Audit(org.asqatasun.entity.audit.Audit) WebResource(org.asqatasun.entity.subject.WebResource) ForbiddenUserException(org.asqatasun.webapp.exception.ForbiddenUserException) ForbiddenPageException(org.asqatasun.webapp.exception.ForbiddenPageException)

Aggregations

Audit (org.asqatasun.entity.audit.Audit)47 WebResource (org.asqatasun.entity.subject.WebResource)11 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)10 Parameter (org.asqatasun.entity.parameterization.Parameter)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 Site (org.asqatasun.entity.subject.Site)7 AuditCommand (org.asqatasun.service.command.AuditCommand)7 ForbiddenUserException (org.asqatasun.webapp.exception.ForbiddenUserException)6 Secured (org.springframework.security.access.annotation.Secured)6 AuditCommandFactory (org.asqatasun.service.command.factory.AuditCommandFactory)5 Contract (org.asqatasun.webapp.entity.contract.Contract)5 Content (org.asqatasun.entity.audit.Content)4 ProcessResult (org.asqatasun.entity.audit.ProcessResult)4 Page (org.asqatasun.entity.subject.Page)4 AuditImpl (org.asqatasun.entity.audit.AuditImpl)3 SSP (org.asqatasun.entity.audit.SSP)2 Test (org.asqatasun.entity.reference.Test)2 ScenarioLoader (org.asqatasun.scenarioloader.ScenarioLoader)2 Act (org.asqatasun.webapp.entity.contract.Act)2 IOException (java.io.IOException)1