use of com.agiletec.aps.system.services.page.IPage 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, true, pageCode, null, null, false, null, null);
Page pageToAdd = PageTestUtil.createPage(pageCode, parentPage.getCode(), "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 com.agiletec.aps.system.services.page.IPage in project entando-core by entando.
the class PageServiceWidgetIntegrationTest method testGetPageConfiguration.
public void testGetPageConfiguration() throws JsonProcessingException {
IPage draftRoot = this.pageManager.getDraftRoot();
PageConfigurationDto pageConfigurationDto = (PageConfigurationDto) this.pageService.getPageConfiguration(draftRoot.getCode(), IPageService.STATUS_DRAFT);
ObjectMapper mapper = new ObjectMapper();
String out = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(pageConfigurationDto);
}
use of com.agiletec.aps.system.services.page.IPage in project entando-core by entando.
the class TestApiWidgetTypeInterface method setPageWidgets.
private void setPageWidgets(String pageCode, int frame, Widget widget) throws ApsSystemException {
IPage page = this._pageManager.getDraftPage(pageCode);
page.getWidgets()[frame] = widget;
this._pageManager.updatePage(page);
}
use of com.agiletec.aps.system.services.page.IPage in project entando-core by entando.
the class ApiWidgetTypeInterface method deleteWidgetType.
public void deleteWidgetType(Properties properties) throws ApiException, Throwable {
String code = properties.getProperty("code");
try {
WidgetType widgetType = this.getWidgetTypeManager().getWidgetType(code);
if (null == widgetType) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Widget Type with code " + code + " does not exists", Response.Status.CONFLICT);
}
if (widgetType.isLocked()) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Widget Type '" + code + "' is locked", Response.Status.CONFLICT);
}
List<IPage> referencedPages = this.getPageManager().getDraftWidgetUtilizers(code);
if (null != referencedPages && !referencedPages.isEmpty()) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "Widget Type '" + code + "' is published into some pages", Response.Status.CONFLICT);
}
this.getWidgetTypeManager().deleteWidgetType(code);
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("Error deleting widget type throw api", t);
throw t;
}
}
use of com.agiletec.aps.system.services.page.IPage in project entando-core by entando.
the class WidgetService method getWidgetInfo.
@Override
public WidgetInfoDto getWidgetInfo(String widgetCode) {
try {
List<IPage> publishedUtilizer = this.getPageManager().getOnlineWidgetUtilizers(widgetCode);
List<IPage> draftUtilizer = this.getPageManager().getDraftWidgetUtilizers(widgetCode);
WidgetType type = this.getWidgetManager().getWidgetType(widgetCode);
WidgetInfoDto info = new WidgetInfoDto();
info.setCode(widgetCode);
info.setTitles(type.getTitles());
publishedUtilizer.stream().forEach(page -> info.addPublishedUtilizer(getWidgetDetails(page, widgetCode)));
draftUtilizer.stream().forEach(page -> info.addDraftUtilizer(getWidgetDetails(page, widgetCode)));
return info;
} catch (ApsSystemException e) {
logger.error("Failed to load widget info for widgetCode {} ", widgetCode);
throw new RestServerError("error in loading widget info", e);
}
}
Aggregations