public static UserRegistry getRegistry(HttpSession session) throws RegistryException { if (session == null) { return org.wso2.carbon.registry.common.utils.CommonUtil.getUserRegistry(registryService); } return org.wso2.carbon.registry.common.utils.CommonUtil.getUserRegistry( registryService, session); } }
public boolean withdrawVote(String imagePath) { try { CommonUtil.getUserRegistry(Utils.getRegistryService()).removeAssociation(DEFAULT_SHUTTERBUG_HOME + RegistryConstants.PATH_SEPARATOR + VOTE_PATH, imagePath, ASSOCIATION_TYPE_VOTED); return true; } catch (Exception e) { log.error("Failed to withdraw vote", e); } return false; }
public boolean vote(String imagePath) { try { CommonUtil.getUserRegistry(Utils.getRegistryService()).addAssociation(DEFAULT_SHUTTERBUG_HOME + RegistryConstants.PATH_SEPARATOR + VOTE_PATH, imagePath, ASSOCIATION_TYPE_VOTED); return true; } catch (Exception e) { log.error("Failed to vote", e); } return false; }
public static UserRegistry getUserRegistry(RegistryService registryService) throws RegistryException { MessageContext messageContext = MessageContext.getCurrentMessageContext(); if (messageContext == null) { String msg = "Could not get the user's Registry session. Message context not found."; log.error(msg); throw new RegistryException(msg); } HttpServletRequest request = (HttpServletRequest) messageContext.getProperty("transport.http.servletRequest"); return getUserRegistry(registryService, request); }
public static String getCurrentUserID() throws Exception { Registry registry = getRegistryService().getSystemRegistry(); Resource shutterbugCollection = registry.get(DEFAULT_SHUTTERBUG_HOME); UserRegistry userRegistry = CommonUtil.getUserRegistry(Utils.getRegistryService()); String tenantUser = TENANT_USER_PREFIX + userRegistry.getTenantId() + "." + userRegistry.getUserName(); return shutterbugCollection.getProperty(tenantUser); }
boolean isAdmin = false; try { String userName = CommonUtil.getUserRegistry(Utils.getRegistryService()).getUserName(); String[] roles = CommonUtil.getUserRegistry(Utils.getRegistryService()).getUserRealm() .getUserStoreManager().getRoleListOfUser(userName); for (String role : roles) {