// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/bean/UserInfoBean.java
// @RequestScoped
// @Named("userInfo")
// public class UserInfoBean {
// 	public static final String ROLE_ADMIN = "admin"; //$NON-NLS-1$
// 
// 	@Inject @Named("darwinoContext")
// 	DarwinoContext context;
// 
// 	@SneakyThrows
// 	public String getImageUrl(final String userName) {
// 		String md5 = StringUtil.md5Hex(StringUtil.toString(userName).toLowerCase());
// 		return StringUtil.format(DarwinoHttpConstants.SOCIAL_USERS_PATH + "/users/{0}/content/photo", URLEncoder.encode(md5, "UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$
// 	}
// 
// 	public boolean isAdmin() {
// 		return context.getUser().hasRole(ROLE_ADMIN);
// 	}
// 
// 	public boolean isAnonymous() {
// 		return context.getUser().isAnonymous();
// 	}
// 
// 	public String getCn() {
// 		return context.getUser().getCn();
// 	}
// 
// 	public String getDn() {
// 		return context.getUser().getDn();
// 	}
// 
// 	public String getEmailAddress() throws UserException {
// 		Object mail = context.getUser().getAttribute(User.ATTR_EMAIL);
// 		return StringUtil.toString(mail);
// 	}
// }
// 
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/MicroPostRepository.java
// @RepositoryProvider(AppDatabaseDef.STORE_MICROPOSTS)
// public interface MicroPostRepository extends DarwinoRepository<MicroPost, String> {
// 	@JSQL("select unid from microposts where $.form='MicroPost' order by $.posted desc")
// 	List<MicroPost> findAll();
// }


import javax.annotation.security.RolesAllowed;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.mvc.Controller;
import javax.mvc.Models;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import bean.UserInfoBean;
import model.MicroPostRepository;
/*
 * Copyright © 2012-2020 Jesse Gallagher
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package controller;



@Path(MicroPostController.PATH)
@RolesAllowed(UserInfoBean.ROLE_ADMIN)
@Controller
@RequestScoped
public class MicroPostController {
	public static final String PATH = "/microposts"; //$NON-NLS-1$

	@Inject Models models;
	@Inject MicroPostRepository microPosts;

	@GET
	public String list() {
		models.put("posts", microPosts.findAll()); //$NON-NLS-1$

		return "microposts.jsp"; //$NON-NLS-1$
	}

	@GET
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/bean/UserInfoBean.java
// @RequestScoped
// @Named("userInfo")
// public class UserInfoBean {
// 	public static final String ROLE_ADMIN = "admin"; //$NON-NLS-1$
// 
// 	@Inject @Named("darwinoContext")
// 	DarwinoContext context;
// 
// 	@SneakyThrows
// 	public String getImageUrl(final String userName) {
// 		String md5 = StringUtil.md5Hex(StringUtil.toString(userName).toLowerCase());
// 		return StringUtil.format(DarwinoHttpConstants.SOCIAL_USERS_PATH + "/users/{0}/content/photo", URLEncoder.encode(md5, "UTF-8")); //$NON-NLS-1$ //$NON-NLS-2$
// 	}
// 
// 	public boolean isAdmin() {
// 		return context.getUser().hasRole(ROLE_ADMIN);
// 	}
// 
// 	public boolean isAnonymous() {
// 		return context.getUser().isAnonymous();
// 	}
// 
// 	public String getCn() {
// 		return context.getUser().getCn();
// 	}
// 
// 	public String getDn() {
// 		return context.getUser().getDn();
// 	}
// 
// 	public String getEmailAddress() throws UserException {
// 		Object mail = context.getUser().getAttribute(User.ATTR_EMAIL);
// 		return StringUtil.toString(mail);
// 	}
// }
// 
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/MicroPostRepository.java
// @RepositoryProvider(AppDatabaseDef.STORE_MICROPOSTS)
// public interface MicroPostRepository extends DarwinoRepository<MicroPost, String> {
// 	@JSQL("select unid from microposts where $.form='MicroPost' order by $.posted desc")
// 	List<MicroPost> findAll();
// }


// Path: frostillicus-blog/frostillicus-blog-j2ee/src/main/java/controller/MicroPostController.java
import javax.annotation.security.RolesAllowed;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.mvc.Controller;
import javax.mvc.Models;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import bean.UserInfoBean;
import model.MicroPostRepository;

/*
 * Copyright © 2012-2020 Jesse Gallagher
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package controller;



@Path(MicroPostController.PATH)
@RolesAllowed(UserInfoBean.ROLE_ADMIN)
@Controller
@RequestScoped
public class MicroPostController {
	public static final String PATH = "/microposts"; //$NON-NLS-1$

	@Inject Models models;
	@Inject MicroPostRepository microPosts;

	@GET
	public String list() {
		models.put("posts", microPosts.findAll()); //$NON-NLS-1$

		return "microposts.jsp"; //$NON-NLS-1$
	}

	@GET
	@Path("{postId}")