use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class LabelService method addLabelGroup.
@Override
public LabelDto addLabelGroup(LabelDto labelRequest) {
try {
BeanPropertyBindingResult validationResult = this.validateAddLabelGroup(labelRequest);
if (validationResult.hasErrors()) {
throw new ValidationGenericException(validationResult);
}
String code = labelRequest.getKey();
ApsProperties languages = new ApsProperties();
languages.putAll(labelRequest.getTitles());
this.getI18nManager().addLabelGroup(code, languages);
return labelRequest;
} catch (ApsSystemException t) {
logger.error("error in add label group with code {}", labelRequest.getKey(), t);
throw new RestServerError("error in add label group", t);
}
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class LabelService method updateLabelGroup.
@Override
public LabelDto updateLabelGroup(LabelDto labelRequest) {
try {
String code = labelRequest.getKey();
ApsProperties labelGroup = this.getI18nManager().getLabelGroup(code);
if (null == labelGroup) {
logger.warn("no label found with key {}", code);
throw new RestRourceNotFoundException(LabelValidator.ERRCODE_LABELGROUP_NOT_FOUND, "label", code);
}
BeanPropertyBindingResult validationResult = this.validateUpdateLabelGroup(labelRequest);
if (validationResult.hasErrors()) {
throw new ValidationGenericException(validationResult);
}
ApsProperties languages = new ApsProperties();
languages.putAll(labelRequest.getTitles());
this.getI18nManager().updateLabelGroup(code, languages);
return labelRequest;
} catch (ApsSystemException t) {
logger.error("error in update label group with code {}", labelRequest.getKey(), t);
throw new RestServerError("error in update label group", t);
}
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class PageService method movePage.
@Override
public PageDto movePage(String pageCode, PagePositionRequest pageRequest) {
IPage parent = this.getPageManager().getDraftPage(pageRequest.getParentCode()), page = this.getPageManager().getDraftPage(pageCode);
boolean moved = true;
int iterations = Math.abs(page.getPosition() - pageRequest.getPosition());
boolean moveUp = page.getPosition() > pageRequest.getPosition();
try {
if (page.getParentCode().equals(parent.getCode())) {
while (iterations-- > 0 && (moved = this.getPageManager().movePage(pageCode, moveUp))) ;
} else {
moved = this.getPageManager().movePage(page, parent);
}
page = this.getPageManager().getDraftPage(pageCode);
} catch (ApsSystemException e) {
logger.error("Error moving page {}", pageCode, e);
throw new RestServerError("error in moving page", e);
}
return this.getDtoBuilder().convert(page);
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class PageService method deleteWidgetConfiguration.
@Override
public void deleteWidgetConfiguration(String pageCode, int frameId) {
try {
IPage page = this.loadPage(pageCode, STATUS_DRAFT);
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));
}
this.pageManager.removeWidget(pageCode, frameId);
} catch (ApsSystemException e) {
logger.error("Error in delete widget configuration for page {} and frame {}", pageCode, frameId, e);
throw new RestServerError("error in delete widget configuration", e);
}
}
use of org.entando.entando.aps.system.exception.RestServerError in project entando-core by entando.
the class PageService method updatePage.
@Override
public PageDto updatePage(String pageCode, PageRequest pageRequest) {
IPage oldPage = this.getPageManager().getDraftPage(pageCode);
if (null == oldPage) {
throw new RestRourceNotFoundException(null, "page", pageCode);
}
this.validateRequest(pageRequest);
try {
IPage newPage = this.updatePage(oldPage, pageRequest);
this.getPageManager().updatePage(newPage);
return this.getDtoBuilder().convert(newPage);
} catch (ApsSystemException e) {
logger.error("Error updating page {}", pageCode, e);
throw new RestServerError("error in update page", e);
}
}
Aggregations