use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class ApiPageModelInterface method deletePageModel.
public void deletePageModel(Properties properties) throws ApiException, Throwable {
String code = properties.getProperty("code");
try {
PageModel pageModel = this.getPageModelManager().getPageModel(code);
if (null == pageModel) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "PageModel with code '" + code + "' does not exist", Response.Status.CONFLICT);
}
Map<String, List<Object>> references = new HashMap<String, List<Object>>();
ListableBeanFactory factory = (ListableBeanFactory) this.getBeanFactory();
String[] defNames = factory.getBeanNamesForType(PageModelUtilizer.class);
for (int i = 0; i < defNames.length; i++) {
Object service = null;
try {
service = this.getBeanFactory().getBean(defNames[i]);
} catch (Throwable t) {
_logger.error("error extracting bean with name '{}'", defNames[i], t);
throw new ApsSystemException("error extracting bean with name '" + defNames[i] + "'", t);
}
if (service != null) {
PageModelUtilizer pageModelUtilizer = (PageModelUtilizer) service;
List<Object> utilizers = pageModelUtilizer.getPageModelUtilizers(code);
if (utilizers != null && !utilizers.isEmpty()) {
references.put(pageModelUtilizer.getName(), utilizers);
}
}
}
if (!references.isEmpty()) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "PageModel with code " + code + " has references with other object", Response.Status.CONFLICT);
}
this.getPageModelManager().deletePageModel(code);
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("Error deleting page model throw api", t);
throw t;
}
}
use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class PageModelAction method extractPageModelFormValues.
protected String extractPageModelFormValues() {
try {
PageModel pageModel = super.getPageModel(this.getCode());
if (null == pageModel) {
this.addActionError(this.getText("error.pageModel.notExist"));
return "pageModelList";
}
this.setDescription(pageModel.getDescription());
this.setPluginCode(pageModel.getPluginCode());
// TO DELETE - start
if (null != pageModel.getConfiguration()) {
PageModelDOM dom = new PageModelDOM(pageModel);
String xml = dom.getXMLDocument();
this.setXmlConfiguration(xml);
}
// TO DELETE - end
this.setTemplate(pageModel.getTemplate());
} catch (Throwable t) {
_logger.error("error in extractPageModelFormValues", t);
return FAILURE;
}
return SUCCESS;
}
use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class PageModelAction method checkModelForDelete.
protected String checkModelForDelete() throws ApsSystemException {
PageModel model = super.getPageModel(this.getCode());
if (null == model) {
this.addActionError(this.getText("error.pageModel.notExist"));
return "pageModelList";
}
this.extractReferencingObjects(this.getCode());
if (null != this.getReferences() && this.getReferences().size() > 0) {
return "references";
}
return null;
}
use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class PageModelAction method createPageModel.
protected PageModel createPageModel() throws Throwable {
PageModel model = null;
try {
if (ApsAdminSystemConstants.ADD == this.getStrutsAction()) {
model = new PageModel();
model.setCode(this.getCode());
} else {
model = this.getPageModel(this.getCode());
}
model.setDescription(this.getDescription());
String template = (!StringUtils.isBlank(this.getTemplate())) ? this.getTemplate() : null;
model.setTemplate(template);
// TO DELETE - start
String xml = this.getXmlConfiguration();
PageModelDOM dom = new PageModelDOM(xml, this.getWidgetTypeManager());
Frame[] configuration = dom.getConfiguration();
int mainFrame = dom.getMainFrame();
if (mainFrame > -1) {
model.setMainFrame(mainFrame);
}
model.setConfiguration(configuration);
// TO DELETE - end
} catch (Throwable t) {
_logger.error("error in creating page model", t);
throw t;
}
return model;
}
use of com.agiletec.aps.system.services.pagemodel.PageModel in project entando-core by entando.
the class PageModelFinderAction method getPageModels.
public List<PageModel> getPageModels() {
List<PageModel> models = new ArrayList<PageModel>();
models.addAll(this.getPageModelManager().getPageModels());
BeanComparator c = new BeanComparator("description");
Collections.sort(models, c);
return models;
}
Aggregations