use of org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto in project entando-core by entando.
the class PageConfigurationController method getPageWidget.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/pages/{pageCode}/widgets/{frameId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getPageWidget(@PathVariable String pageCode, @PathVariable int frameId, @RequestParam(value = "status", required = false, defaultValue = IPageService.STATUS_DRAFT) String status) {
logger.trace("requested widget detail for page {} and frame {}", pageCode, frameId);
WidgetConfigurationDto widgetConfiguration = this.getPageService().getWidgetConfiguration(pageCode, frameId, status);
Map<String, String> metadata = new HashMap<>();
metadata.put("status", status);
return new ResponseEntity<>(new RestResponse(widgetConfiguration, null, metadata), HttpStatus.OK);
}
use of org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto in project entando-core by entando.
the class PageService method getWidgetConfiguration.
@Override
public WidgetConfigurationDto getWidgetConfiguration(String pageCode, int frameId, String status) {
IPage page = this.loadPage(pageCode, status);
if (null == page) {
throw new RestRourceNotFoundException(ERRCODE_PAGE_NOT_FOUND, "page", pageCode);
}
if (frameId > page.getWidgets().length) {
throw new RestRourceNotFoundException(ERRCODE_FRAME_INVALID, "frame", String.valueOf(frameId));
}
Widget widget = page.getWidgets()[frameId];
if (null == widget) {
return null;
}
return new WidgetConfigurationDto(widget);
}
use of org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto in project entando-core by entando.
the class PageServiceWidgetIntegrationTest method testUpdatePageWidget.
public void testUpdatePageWidget() throws JsonProcessingException, ApsSystemException {
String pageCode = "temp001";
IPage parentPage = pageManager.getDraftRoot();
PageModel pageModel = parentPage.getMetadata().getModel();
PageMetadata metadata = PageTestUtil.createPageMetadata(pageModel.getCode(), true, pageCode, null, null, false, null, null);
Page pageToAdd = PageTestUtil.createPage(pageCode, parentPage, "free", metadata, null);
try {
pageManager.addPage(pageToAdd);
WidgetConfigurationDto widgetConfigurationDto = this.pageService.getWidgetConfiguration(pageToAdd.getCode(), 0, IPageService.STATUS_DRAFT);
assertThat(widgetConfigurationDto, is(nullValue()));
WidgetConfigurationRequest widgetConfigurationRequest = new WidgetConfigurationRequest();
widgetConfigurationRequest.setCode("login_form");
widgetConfigurationRequest.setConfig(null);
this.pageService.updateWidgetConfiguration(pageCode, 0, widgetConfigurationRequest);
assertThat(this.pageService.getWidgetConfiguration(pageToAdd.getCode(), 0, IPageService.STATUS_DRAFT).getCode(), is("login_form"));
} finally {
pageManager.deletePage(pageCode);
}
}
use of org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto in project entando-core by entando.
the class PageConfigurationController method updatePageWidget.
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/pages/{pageCode}/widgets/{frameId}", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> updatePageWidget(@PathVariable String pageCode, @PathVariable int frameId, @Valid @RequestBody WidgetConfigurationRequest widget, BindingResult bindingResult) {
logger.trace("updating widget configuration in page {} and frame {}", pageCode, frameId);
WidgetConfigurationDto widgetConfiguration = this.getPageService().updateWidgetConfiguration(pageCode, frameId, widget);
Map<String, String> metadata = new HashMap<>();
metadata.put("status", IPageService.STATUS_DRAFT);
return new ResponseEntity<>(new RestResponse(widgetConfiguration, null, metadata), HttpStatus.OK);
}
use of org.entando.entando.aps.system.services.page.model.WidgetConfigurationDto in project entando-core by entando.
the class PageServiceWidgetIntegrationTest method testGetPageWidget.
public void testGetPageWidget() throws JsonProcessingException {
IPage draftRoot = this.pageManager.getDraftRoot();
WidgetConfigurationDto widgetConfigurationDto = this.pageService.getWidgetConfiguration(draftRoot.getCode(), 0, IPageService.STATUS_DRAFT);
assertThat(widgetConfigurationDto.getCode(), is("content_viewer_list"));
}
Aggregations