/** * ユーザーリスト * * @return */ public SitePage getByName(User user, String name) { return Datastore.query(meta) .filter( meta.userRef.equal(user.getKey()), meta.name.equal(name), meta.template.equal(user.getTemplate())) .asSingle(); }
/** * インデックスページの取得 * * @return */ public SitePage getIndexPage(User user) { return Datastore.query(meta) .filter( meta.userRef.equal(user.getKey()), meta.template.equal(user.getTemplate()), meta.role.equal("index")) .asSingle(); }
/** * ユーザーリスト * * @return */ public List<SitePage> getList(User user) { return Datastore.query(meta) .filter( meta.userRef.equal(user.getKey()), meta.template.equal(user.getTemplate()), meta.published.equal(true)) .sort(meta.sortOrder.asc, meta.createDate.asc) .asList(); }
/** * リソースの設定 * * @param user * @param pageRole */ protected void setRes(User user, SitePage sitePage) { PageRoleModel pageRole = user.getTemplate().getPageRoleMap().get(sitePage.getRole()); if (pageRole.getListTypes() != null) { for (ListItemType listType : pageRole.getListTypes()) { HashMap<String, String> textResMap = new HashMap<String, String>(); List<ListItem> list = setItemList(user, listType); for (ListItem listItem : list) { List<TextRes> itemTextResList = listItem.getTextResListRef().getModelList(); for (TextRes res : itemTextResList) textResMap.put(res.getKey().getName(), res.getContentString()); } requestScope(listType + "TextMap", textResMap); } } List<TextRes> pageTextResList = sitePage.getTextResListRef().getModelList(); HashMap<String, String> pageTextResMap = new HashMap<String, String>(); for (TextRes res : pageTextResList) pageTextResMap.put(res.getKey().getName(), res.getContentString()); requestScope("pageTextResMap", pageTextResMap); List<GcsRes> pageGcsResList = sitePage.getGcsResListRef().getModelList(); HashMap<String, String> pageGcsResMap = new HashMap<String, String>(); for (GcsRes res : pageGcsResList) pageGcsResMap.put(res.getKey().getName(), res.getServingUrl()); requestScope("pageGcsResMap", pageGcsResMap); }
@Override public Navigation run() throws Exception { requestScope("isSmartPhone", String.valueOf(isSmartPhone())); requestScope("isLocal", String.valueOf(isLocal())); String siteId = asString("siteId"); if (StringUtil.isEmpty(siteId.trim())) throw new NoContentsException(); User user = null; try { user = UserService.getBySiteId(siteId); requestScope("user", user); } catch (ObjectNotExistException e) { throw new NoContentsException(); } List<SitePage> pageList = null; try { pageList = PageService.getList(user); requestScope("pageList", pageList); } catch (ObjectNotExistException e) { throw new NoContentsException(); } try { if (user.getSiteId().equals(getLoginUser().getSiteId())) { requestScope("isEditMode", String.valueOf(true)); } else { requestScope("isEditMode", String.valueOf(false)); } } catch (NoLoginException e) { requestScope("isEditMode", String.valueOf(false)); } return execute(user); }