// 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;
/*
 * 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;



@Controller
@Path("admin")
@RolesAllowed(UserInfoBean.ROLE_ADMIN)
@RequestScoped
public class AdminController {
	@Inject
	LinkRepository links;
	@Inject
// 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;

/*
 * 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;



@Controller
@Path("admin")
@RolesAllowed(UserInfoBean.ROLE_ADMIN)
@RequestScoped
public class AdminController {
	@Inject
	LinkRepository links;
	@Inject
	AccessTokenRepository tokens;