Search in sources :

Example 11 with UserDO

use of com.alibaba.cobar.manager.dataobject.xml.UserDO in project cobar by alibaba.

the class ForbiddenScreen method handleRequestInternal.

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    UserDO user = (UserDO) request.getSession().getAttribute("user");
    String lastUrl = request.getHeader("Referer");
    return new ModelAndView("forbidden", new FluenceHashMap<String, Object>().putKeyValue("user", user).putKeyValue("lastUrl", lastUrl));
}
Also used : UserDO(com.alibaba.cobar.manager.dataobject.xml.UserDO) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 12 with UserDO

use of com.alibaba.cobar.manager.dataobject.xml.UserDO in project cobar by alibaba.

the class MClusterListScreen method handleRequestInternal.

@SuppressWarnings("unchecked")
@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    UserDO user = (UserDO) request.getSession().getAttribute("user");
    List<ClusterDO> list = xmlAccesser.getClusterDAO().listAllCluster();
    List<Map<String, Object>> clusterList = new ArrayList<Map<String, Object>>();
    ListSortUtil.sortClusterBySortId(list);
    PropertyUtilsBean util = new PropertyUtilsBean();
    for (ClusterDO e : list) {
        int count = xmlAccesser.getCobarDAO().getCobarList(e.getId(), ConstantDefine.ACTIVE).size();
        count += xmlAccesser.getCobarDAO().getCobarList(e.getId(), ConstantDefine.IN_ACTIVE).size();
        Map<String, Object> map;
        try {
            map = util.describe(e);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
        map.remove("class");
        map.remove("name");
        map.remove("deployDesc");
        map.put("name", CobarStringUtil.htmlEscapedString(e.getName()));
        map.put("deployContact", CobarStringUtil.htmlEscapedString(e.getDeployContact()));
        map.put("cobarNum", count);
        clusterList.add(map);
    }
    return new ModelAndView("m_clusterList", new FluenceHashMap<String, Object>().putKeyValue("clusterList", clusterList).putKeyValue("user", user));
}
Also used : PropertyUtilsBean(org.apache.commons.beanutils.PropertyUtilsBean) UserDO(com.alibaba.cobar.manager.dataobject.xml.UserDO) ArrayList(java.util.ArrayList) ModelAndView(org.springframework.web.servlet.ModelAndView) ClusterDO(com.alibaba.cobar.manager.dataobject.xml.ClusterDO) FluenceHashMap(com.alibaba.cobar.manager.util.FluenceHashMap) Map(java.util.Map)

Example 13 with UserDO

use of com.alibaba.cobar.manager.dataobject.xml.UserDO in project cobar by alibaba.

the class MPropertyListScreen method handleRequestInternal.

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    UserDO user = (UserDO) request.getSession().getAttribute("user");
    List<Integer> pList = xmlAccesser.getPropertyDAO().getProperty().getStopTimes();
    return new ModelAndView("m_propertyList", new FluenceHashMap<String, Object>().putKeyValue("user", user).putKeyValue("pList", pList));
}
Also used : UserDO(com.alibaba.cobar.manager.dataobject.xml.UserDO) ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 14 with UserDO

use of com.alibaba.cobar.manager.dataobject.xml.UserDO in project cobar by alibaba.

the class UserDAOImple method read.

private boolean read() {
    FileInputStream is = null;
    lock.lock();
    try {
        map.clear();
        is = new FileInputStream(xmlPath);
        xpp.setInput(is, "UTF-8");
        while (!(xpp.getEventType() == XmlPullParser.END_TAG && "users".equals(xpp.getName()))) {
            if (xpp.getEventType() == XmlPullParser.START_TAG && "user".equals(xpp.getName())) {
                UserDO user = read(xpp);
                if (null == user) {
                    throw new XmlPullParserException("User read error");
                }
                maxId = (maxId < user.getId()) ? user.getId() : maxId;
                map.put(user.getId(), user);
            }
            xpp.next();
        }
        is.close();
        return true;
    } catch (FileNotFoundException e) {
        logger.error(e.getMessage(), e);
    } catch (XmlPullParserException e) {
        logger.error(e.getMessage(), e);
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
    } finally {
        maxId = maxId < 0 ? 0 : maxId;
        lock.unlock();
    }
    if (null != is) {
        try {
            is.close();
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
        }
    }
    return false;
}
Also used : UserDO(com.alibaba.cobar.manager.dataobject.xml.UserDO) FileNotFoundException(java.io.FileNotFoundException) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream)

Example 15 with UserDO

use of com.alibaba.cobar.manager.dataobject.xml.UserDO in project cobar by alibaba.

the class UserDAOImple method checkName.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public boolean checkName(String username) {
    Iterator it = map.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry<Long, UserDO> entry = (Entry<Long, UserDO>) it.next();
        UserDO user = entry.getValue();
        if (username.equals(user.getUsername())) {
            return false;
        }
    }
    return true;
}
Also used : Entry(java.util.Map.Entry) UserDO(com.alibaba.cobar.manager.dataobject.xml.UserDO) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

UserDO (com.alibaba.cobar.manager.dataobject.xml.UserDO)39 ModelAndView (org.springframework.web.servlet.ModelAndView)22 HashMap (java.util.HashMap)15 Map (java.util.Map)15 ClusterDO (com.alibaba.cobar.manager.dataobject.xml.ClusterDO)11 CobarDO (com.alibaba.cobar.manager.dataobject.xml.CobarDO)10 FluenceHashMap (com.alibaba.cobar.manager.util.FluenceHashMap)10 ArrayList (java.util.ArrayList)10 CobarAdapterDAO (com.alibaba.cobar.manager.dao.CobarAdapterDAO)7 PropertyUtilsBean (org.apache.commons.beanutils.PropertyUtilsBean)5 Test (org.junit.Test)5 Iterator (java.util.Iterator)4 Entry (java.util.Map.Entry)4 IOException (java.io.IOException)3 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)3 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)3 MockHttpSession (org.springframework.mock.web.MockHttpSession)3 UserDAOImple (com.alibaba.cobar.manager.dao.xml.UserDAOImple)1 ConnectionStatus (com.alibaba.cobar.manager.dataobject.cobarnode.ConnectionStatus)1 DataNodesStatus (com.alibaba.cobar.manager.dataobject.cobarnode.DataNodesStatus)1