}
@Override
public PageRequestVO getPageRequest(final Long id, final String parentUrl) {
try {
PageRequestVO result = new PageRequestVO();
PageEntity page = getPage(id);
result.setPage(page);
result.setConfig(VosaoContext.getInstance().getConfig());
String permUrl = parentUrl;
if (page != null) {
String url = page.getFriendlyURL();
result.setVersions(getPageVersions(url));
result.setChildren(getChildren(url));
result.setComments(getCommentService().getByPage(url));
result.setContents(getContents(id));
result.setPermissions(getContentPermissionService()
.selectByUrl(url));
result.setTags(getPageTags(url));
permUrl = page.getFriendlyURL();
if (page.isStructured()) {
StructureEntity structure = getDao().getStructureDao()
.getById(page.getStructureId());
if (structure != null) {
result.setStructureFields(structure.getFields());
}
}
result.setDependencies(getDependencies(page.getFriendlyURL()));
FolderEntity folder = getBusiness().getPageBusiness()
.getPageFolder(page.getFriendlyURL());
result.setFolderId(folder != null ? folder.getId() : null);
}
else {
result.setPage(getPageBusiness().getPageDefaultSettings(
parentUrl));
result.getPage().setId(null);
result.getPage().setFriendlyURL("");
result.getPage().setParentFriendlyURL(parentUrl);
result.setChildren(Collections.EMPTY_LIST);
result.setVersions(Collections.EMPTY_LIST);
result.setComments(Collections.EMPTY_LIST);
result.setPermissions(Collections.EMPTY_LIST);
result.setTags(Collections.EMPTY_LIST);
}
if (result.getContents() == null
|| result.getContents().size() == 0) {
PageEntity defaultPage = getPageBusiness()
.getPageDefaultSettings(parentUrl);
result.setContents(getDao().getPageDao().getContents(
defaultPage.getId()));
}
result.setTemplates(getTemplateService().getTemplates());
result.setLanguages(getLanguageService().select());
result.setGroups(getGroupService().select());
result.setPagePermission(getContentPermissionService()
.getPermission(permUrl));
result.setStructures(getDao().getStructureDao().select());
return result;
} catch (Exception e) {
e.printStackTrace();
return null;
}