// 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/AccessToken.java
// @Entity @Data @NoArgsConstructor
// public class AccessToken {
// 	@Id @Column private String id;
// 	@Column private String userName;
// 	@Column private String name;
// 	@Column private String token;
// 	@Column private boolean isConflict;
// }
// 
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessTokenRepository.java
// @RepositoryProvider(AppDatabaseDef.STORE_TOKENS)
// public interface AccessTokenRepository extends DarwinoRepository<AccessToken, String> {
// 	Stream<AccessToken> findAll();
// 
// 	Optional<AccessToken> findByToken(String token);
// }
// 
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/Link.java
// @Entity @Data @NoArgsConstructor
// public class Link {
// 	@Id @Column private String id;
// 	@Column private String category;
// 	@Column("link_url") @NotEmpty private String url;
// 	@Column("link_name") @NotEmpty private String name;
// 	@Column("link_visible") @Convert(BooleanYNConverter.class) private boolean visible;
// 	@Column private String rel;
// 	@Column private boolean isConflict;
// }
// 
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/LinkRepository.java
// @RepositoryProvider(AppDatabaseDef.STORE_CONFIG)
// public interface LinkRepository extends DarwinoRepository<Link, String> {
// 	Stream<Link> findAll();
// 
// 	@Query("select * from Link order by category name")
// 	List<Link> findAllByCategoryAndName();
// }


import bean.UserInfoBean;
import com.darwino.commons.json.JsonException;
import com.darwino.jsonstore.Session;
import model.AccessToken;
import model.AccessTokenRepository;
import model.Link;
import model.LinkRepository;
import javax.annotation.security.RolesAllowed;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.mvc.Controller;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.UUID;
	@POST
	@Path("links/{linkId}")
	public String update(
			@PathParam("linkId") final String linkId,
			@FormParam("visible") final String visible,
			@FormParam("category") final String category,
			@FormParam("name") final String name,
			@FormParam("url") final String url,
			@FormParam("rel") final String rel
		) {
		var link = links.findById(linkId).orElseThrow(() -> new NotFoundException("Unable to find link matching ID " + linkId)); //$NON-NLS-1$
		link.setVisible("Y".equals(visible)); //$NON-NLS-1$
		link.setCategory(category);
		link.setName(name);
		link.setUrl(url);
		link.setRel(rel);
		links.save(link);
		return "redirect:admin"; //$NON-NLS-1$
	}

	@DELETE
	@Path("links/{linkId}")
	public String deleteLink(@PathParam("linkId") final String linkId) {
		links.deleteById(linkId);
		return "redirect:admin"; //$NON-NLS-1$
	}

	@POST
	@Path("links/new")
	public String createLink() {
// 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/AccessToken.java
// @Entity @Data @NoArgsConstructor
// public class AccessToken {
// 	@Id @Column private String id;
// 	@Column private String userName;
// 	@Column private String name;
// 	@Column private String token;
// 	@Column private boolean isConflict;
// }
// 
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/AccessTokenRepository.java
// @RepositoryProvider(AppDatabaseDef.STORE_TOKENS)
// public interface AccessTokenRepository extends DarwinoRepository<AccessToken, String> {
// 	Stream<AccessToken> findAll();
// 
// 	Optional<AccessToken> findByToken(String token);
// }
// 
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/Link.java
// @Entity @Data @NoArgsConstructor
// public class Link {
// 	@Id @Column private String id;
// 	@Column private String category;
// 	@Column("link_url") @NotEmpty private String url;
// 	@Column("link_name") @NotEmpty private String name;
// 	@Column("link_visible") @Convert(BooleanYNConverter.class) private boolean visible;
// 	@Column private String rel;
// 	@Column private boolean isConflict;
// }
// 
// Path: frostillicus-blog/frostillicus-blog-shared/src/main/java/model/LinkRepository.java
// @RepositoryProvider(AppDatabaseDef.STORE_CONFIG)
// public interface LinkRepository extends DarwinoRepository<Link, String> {
// 	Stream<Link> findAll();
// 
// 	@Query("select * from Link order by category name")
// 	List<Link> findAllByCategoryAndName();
// }


// Path: frostillicus-blog/frostillicus-blog-j2ee/src/main/java/controller/AdminController.java
import bean.UserInfoBean;
import com.darwino.commons.json.JsonException;
import com.darwino.jsonstore.Session;
import model.AccessToken;
import model.AccessTokenRepository;
import model.Link;
import model.LinkRepository;
import javax.annotation.security.RolesAllowed;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.mvc.Controller;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.UUID;

	@POST
	@Path("links/{linkId}")
	public String update(
			@PathParam("linkId") final String linkId,
			@FormParam("visible") final String visible,
			@FormParam("category") final String category,
			@FormParam("name") final String name,
			@FormParam("url") final String url,
			@FormParam("rel") final String rel
		) {
		var link = links.findById(linkId).orElseThrow(() -> new NotFoundException("Unable to find link matching ID " + linkId)); //$NON-NLS-1$
		link.setVisible("Y".equals(visible)); //$NON-NLS-1$
		link.setCategory(category);
		link.setName(name);
		link.setUrl(url);
		link.setRel(rel);
		links.save(link);
		return "redirect:admin"; //$NON-NLS-1$
	}

	@DELETE
	@Path("links/{linkId}")
	public String deleteLink(@PathParam("linkId") final String linkId) {
		links.deleteById(linkId);
		return "redirect:admin"; //$NON-NLS-1$
	}

	@POST
	@Path("links/new")
	public String createLink() {
		var link = new Link();