Search in sources :

Example 6 with ErrorModel

use of com.developmentontheedge.be5.model.jsonapi.ErrorModel in project be5 by DevelopmentOnTheEdge.

the class StaticPageComponent method generate.

@Override
public void generate(Request req, Response res, Injector injector) {
    String language = UserInfoHolder.getLanguage();
    String page = req.getRequestUri();
    String staticPageContent = injector.getProject().getStaticPageContent(language, page);
    if (staticPageContent == null) {
        // todo localize
        res.sendErrorAsJson(new ErrorModel("500", ErrorTitles.formatTitle(Be5ErrorCode.NOT_FOUND, page), Collections.singletonMap(SELF_LINK, "static/" + page)), req.getDefaultMeta());
    } else {
        res.sendAsJson(new ResourceData(STATIC_ACTION, new StaticPagePresentation("", staticPageContent), Collections.singletonMap(SELF_LINK, "static/" + page)), req.getDefaultMeta());
    }
}
Also used : ResourceData(com.developmentontheedge.be5.model.jsonapi.ResourceData) StaticPagePresentation(com.developmentontheedge.be5.model.StaticPagePresentation) ErrorModel(com.developmentontheedge.be5.model.jsonapi.ErrorModel)

Aggregations

ErrorModel (com.developmentontheedge.be5.model.jsonapi.ErrorModel)6 ResourceData (com.developmentontheedge.be5.model.jsonapi.ResourceData)4 Be5Exception (com.developmentontheedge.be5.api.exceptions.Be5Exception)2 StaticPagePresentation (com.developmentontheedge.be5.model.StaticPagePresentation)2 DocumentGenerator (com.developmentontheedge.be5.query.DocumentGenerator)2 OperationExecutor (com.developmentontheedge.be5.api.services.OperationExecutor)1 Entity (com.developmentontheedge.be5.metadata.model.Entity)1 Query (com.developmentontheedge.be5.metadata.model.Query)1 FormPresentation (com.developmentontheedge.be5.model.FormPresentation)1 JsonApiModel (com.developmentontheedge.be5.model.jsonapi.JsonApiModel)1 Operation (com.developmentontheedge.be5.operation.Operation)1 OperationResult (com.developmentontheedge.be5.operation.OperationResult)1 Be5QueryExecutor (com.developmentontheedge.be5.query.impl.model.Be5QueryExecutor)1 HashUrl (com.developmentontheedge.be5.util.HashUrl)1 SqlQuery (com.developmentontheedge.sql.model.SqlQuery)1