Search in sources :

Example 1 with Request

use of com.developmentontheedge.be5.api.Request in project be5 by DevelopmentOnTheEdge.

the class DownloadComponentTest method test.

@Test
@Ignore
public void test() {
    Response response = mock(Response.class);
    Request req = getSpyMockRequest("", ImmutableMap.<String, String>builder().put("_t_", "attachments").put("_typeColumn_", "mimeType").put("_charsetColumn_", "mimeCharset").put("_filenameColumn_", "name").put("_dataColumn_", "data").put("_download_", "no").put("ID", "7326").build());
    component.generate(req, response, injector);
}
Also used : Response(com.developmentontheedge.be5.api.Response) Request(com.developmentontheedge.be5.api.Request) Ignore(org.junit.Ignore) Test(org.junit.Test) Be5ProjectTest(com.developmentontheedge.be5.test.Be5ProjectTest)

Example 2 with Request

use of com.developmentontheedge.be5.api.Request in project be5 by DevelopmentOnTheEdge.

the class AuthenticationPropagationListener method requestInitialized.

@Override
public void requestInitialized(ServletRequestEvent event) {
    HttpServletRequest request = (HttpServletRequest) event.getServletRequest();
    HttpSession session = request.getSession(false);
    if (session == null) {
        return;
    }
    UserInfo user = (UserInfo) session.getAttribute(SessionConstants.USER_INFO);
    UserInfoHolder.setUserInfo(user);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpSession(javax.servlet.http.HttpSession) UserInfo(com.developmentontheedge.be5.model.UserInfo)

Example 3 with Request

use of com.developmentontheedge.be5.api.Request in project be5 by DevelopmentOnTheEdge.

the class TestUtils method getMockRequest.

protected Request getMockRequest(String requestUri) {
    Request request = mock(Request.class);
    when(request.getRequestUri()).thenReturn(requestUri);
    return request;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(com.developmentontheedge.be5.api.Request)

Example 4 with Request

use of com.developmentontheedge.be5.api.Request in project be5 by DevelopmentOnTheEdge.

the class UserHelper method initGuest.

public void initGuest(Request req) {
    Locale locale = Locale.US;
    String remoteAddr = "";
    Session session;
    if (req != null) {
        locale = req.getLocale();
        remoteAddr = req.getRemoteAddr();
        session = req.getSession();
    } else {
        session = new TestSession();
    }
    if (ModuleLoader2.getDevRoles().size() > 0) {
        saveUser("dev", ModuleLoader2.getDevRoles(), ModuleLoader2.getDevRoles(), locale, remoteAddr, session);
    } else {
        List<String> roles = Collections.singletonList(RoleType.ROLE_GUEST);
        saveUser(RoleType.ROLE_GUEST, roles, roles, locale, remoteAddr, session);
    }
}
Also used : Locale(java.util.Locale) TestSession(com.developmentontheedge.be5.test.TestSession) TestSession(com.developmentontheedge.be5.test.TestSession) Session(com.developmentontheedge.be5.api.Session)

Example 5 with Request

use of com.developmentontheedge.be5.api.Request in project be5 by DevelopmentOnTheEdge.

the class Document method sendError.

private void sendError(Request req, Response res, HashUrl url, Be5Exception e) {
    String message = "";
    // message += GroovyRegister.getErrorCodeLine(e, query.getQuery());
    res.sendErrorAsJson(new ErrorModel(e, message, Collections.singletonMap(SELF_LINK, url.toString())), req.getDefaultMeta());
}
Also used : ErrorModel(com.developmentontheedge.be5.model.jsonapi.ErrorModel)

Aggregations

Request (com.developmentontheedge.be5.api.Request)8 Response (com.developmentontheedge.be5.api.Response)6 ResourceData (com.developmentontheedge.be5.model.jsonapi.ResourceData)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 Be5Exception (com.developmentontheedge.be5.api.exceptions.Be5Exception)5 ErrorModel (com.developmentontheedge.be5.model.jsonapi.ErrorModel)5 Be5ProjectTest (com.developmentontheedge.be5.test.Be5ProjectTest)5 Test (org.junit.Test)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 UserAwareMeta (com.developmentontheedge.be5.api.helpers.UserAwareMeta)3 Query (com.developmentontheedge.be5.metadata.model.Query)3 DocumentGenerator (com.developmentontheedge.be5.query.DocumentGenerator)3 Map (java.util.Map)3 Session (com.developmentontheedge.be5.api.Session)2 UserHelper (com.developmentontheedge.be5.api.helpers.UserHelper)2 RequestImpl (com.developmentontheedge.be5.api.impl.RequestImpl)2 StaticPagePresentation (com.developmentontheedge.be5.model.StaticPagePresentation)2 UserInfo (com.developmentontheedge.be5.model.UserInfo)2 JsonApiModel (com.developmentontheedge.be5.model.jsonapi.JsonApiModel)2 HashUrl (com.developmentontheedge.be5.util.HashUrl)2