use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class PageConfigurationControllerIntegrationTest method createPage.
protected Page createPage(String pageCode) {
IPage parentPage = pageManager.getDraftPage("service");
PageModel pageModel = parentPage.getMetadata().getModel();
PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel.getCode(), true, pageCode + "_title", null, null, false, null, null);
ApsProperties config = PageTestUtil.createProperties("temp", "tempValue", "contentId", "ART11");
Widget widgetToAdd = PageTestUtil.createWidget("content_viewer", config, this.widgetTypeManager);
Widget[] widgets = { widgetToAdd };
Page pageToAdd = PageTestUtil.createPage(pageCode, parentPage, "free", metadata, widgets);
return pageToAdd;
}
use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class PageModelControllerIntegrationTest method testDeletePageModel.
@Test
public void testDeletePageModel() throws Exception {
String pageModelCode = "testPM";
try {
PageModel pageModel = new PageModel();
pageModel.setCode(pageModelCode);
pageModel.setDescription(pageModelCode);
this.pageModelManager.addPageModel(pageModel);
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
ResultActions result = mockMvc.perform(delete("/pagemodels/{code}", pageModelCode).contentType(MediaType.APPLICATION_JSON_VALUE).header("Authorization", "Bearer " + accessToken));
// System.out.println(result.andReturn().getResponse().getContentAsString());
result.andExpect(status().isOk());
} finally {
this.pageModelManager.deletePageModel(pageModelCode);
}
}
use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class PageModelControllerTest method should_load_the_list_of_pageModels_1.
@Test
public void should_load_the_list_of_pageModels_1() throws Exception {
UserDetails user = new OAuth2TestUtils.UserBuilder("jack_bauer", "0x24").grantedToRoleAdmin().build();
String accessToken = mockOAuthInterceptor(user);
PageModelDto singleDto = new PageModelDto();
List<PageModelDto> dtos = new ArrayList<>();
dtos.add(singleDto);
PageModel model = new PageModel();
List<PageModel> models = new ArrayList<>();
models.add(model);
SearcherDaoPaginatedResult<PageModel> sdpr = new SearcherDaoPaginatedResult<>(1, models);
PagedMetadata<PageModelDto> meta = new PagedMetadata<>(new RestListRequest(), sdpr);
meta.setBody(dtos);
when(pageModelService.getPageModels(any(RestListRequest.class))).thenReturn(meta);
ResultActions result = mockMvc.perform(get("/pagemodels").header("Authorization", "Bearer " + accessToken));
System.out.println(result.andReturn().getResponse().getContentAsString());
result.andExpect(status().isOk());
RestListRequest restListReq = new RestListRequest();
Mockito.verify(pageModelService, Mockito.times(1)).getPageModels(restListReq);
}
use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class PageExecutorService method service.
@Override
public void service(RequestContext reqCtx) {
HttpServletRequest request = reqCtx.getRequest();
HttpServletResponse response = reqCtx.getResponse();
try {
if (response.isCommitted()) {
return;
}
IPage page = (IPage) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_CURRENT_PAGE);
PageModel model = page.getModel();
if (StringUtils.isBlank(model.getTemplate())) {
String jspPath = model.getPageModelJspPath();
RequestDispatcher dispatcher = request.getSession().getServletContext().getRequestDispatcher(jspPath);
dispatcher.forward(request, response);
} else {
ExecutorBeanContainer ebc = (ExecutorBeanContainer) reqCtx.getExtraParam(SystemConstants.EXTRAPAR_EXECUTOR_BEAN_CONTAINER);
Template template = new Template(page.getCode(), new StringReader(model.getTemplate()), ebc.getConfiguration());
try {
template.process(ebc.getTemplateModel(), response.getWriter());
} catch (Throwable t) {
String msg = "Error detected while including a page model " + model.getCode();
_logger.error(msg, t);
throw new RuntimeException(msg, t);
}
}
} catch (ServletException e) {
String msg = "Error detected while including a page model";
_logger.error(msg, e);
throw new RuntimeException(msg, e);
} catch (IOException e) {
String msg = "IO error detected while including the page model";
_logger.error(msg, e);
throw new RuntimeException(msg, e);
}
}
use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class PageManager method checkPagePos.
/**
* Utility method which perform checks on the parameters submitted when
* editing the page.
*
* @param pageCode The code of the page
* @param pos The given position
* @throws ApsSystemException In case of database access error.
*/
private void checkPagePos(String pageCode, int pos) throws ApsSystemException {
IPage currentPage = this.getDraftPage(pageCode);
if (null == currentPage) {
throw new ApsSystemException("The page '" + pageCode + "' does not exist!");
}
PageModel model = currentPage.getMetadata().getModel();
if (pos < 0 || pos >= model.getFrames().length) {
throw new ApsSystemException("The Position '" + pos + "' is not defined in the model '" + model.getDescription() + "' of the page '" + pageCode + "'!");
}
}
Aggregations