Package com.cloud.ucs.structure

Examples of com.cloud.ucs.structure.UcsCookie


        }
    }

    private String getCookie(Long ucsMgrId) {
        try {
            UcsCookie ucsCookie = cookies.get(ucsMgrId);
            long currentTime = System.currentTimeMillis();
            UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
            UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
            String cmd = null;
            if (ucsCookie == null) {
                cmd = UcsCommands.loginCmd(mgrvo.getUsername(), mgrvo.getPassword());
            }
            else {
                String cookie = ucsCookie.getCookie();
                long cookieStartTime = ucsCookie.getStartTime();
                if(currentTime - cookieStartTime > COOKIE_TTL) {
                    cmd = UcsCommands.loginCmd(mgrvo.getUsername(), mgrvo.getPassword());
                }
                else if(currentTime - cookieStartTime > COOKIE_REFRESH_TTL) {
                    cmd = UcsCommands.refreshCmd(mgrvo.getUsername(), mgrvo.getPassword(), cookie);
                }
            }
            if(!(cmd == null)) {
                String ret = client.call(cmd);
                XmlObject xo = XmlObjectParser.parseFromString(ret);
                String cookie = xo.get("outCookie");
                ucsCookie = new UcsCookie(cookie, currentTime);
                cookies.put(ucsMgrId, ucsCookie);
                //cookiesTime.put(cookie, currentTime); //This is currentTime on purpose, and not latest time.
            }
            return ucsCookie.getCookie();
        } catch (Exception e) {
            throw new CloudRuntimeException("Cannot get cookie", e);
        }
    }
View Full Code Here


        }
    }

    private String getCookie(Long ucsMgrId) {
        try {
            UcsCookie ucsCookie = cookies.get(ucsMgrId);
            long currentTime = System.currentTimeMillis();
            UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
            UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
            String cmd = null;
            if (ucsCookie == null) {
                cmd = UcsCommands.loginCmd(mgrvo.getUsername(), mgrvo.getPassword());
            } else {
                String cookie = ucsCookie.getCookie();
                long cookieStartTime = ucsCookie.getStartTime();
                if (currentTime - cookieStartTime > COOKIE_TTL) {
                    cmd = UcsCommands.loginCmd(mgrvo.getUsername(), mgrvo.getPassword());
                } else if (currentTime - cookieStartTime > COOKIE_REFRESH_TTL) {
                    cmd = UcsCommands.refreshCmd(mgrvo.getUsername(), mgrvo.getPassword(), cookie);
                }
            }
            if (!(cmd == null)) {
                String ret = client.call(cmd);
                XmlObject xo = XmlObjectParser.parseFromString(ret);
                String cookie = xo.get("outCookie");
                ucsCookie = new UcsCookie(cookie, currentTime);
                cookies.put(ucsMgrId, ucsCookie);
                //cookiesTime.put(cookie, currentTime); //This is currentTime on purpose, and not latest time.
            }
            return ucsCookie.getCookie();
        } catch (Exception e) {
            throw new CloudRuntimeException("Cannot get cookie", e);
        }
    }
View Full Code Here

        }
    }

    private String getCookie(Long ucsMgrId) {
        try {
            UcsCookie ucsCookie = cookies.get(ucsMgrId);
            long currentTime = System.currentTimeMillis();
            UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
            UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
            String cmd = null;
            if (ucsCookie == null) {
                cmd = UcsCommands.loginCmd(mgrvo.getUsername(), mgrvo.getPassword());
            }
            else {
                String cookie = ucsCookie.getCookie();
                long cookieStartTime = ucsCookie.getStartTime();
                if(currentTime - cookieStartTime > COOKIE_TTL) {
                    cmd = UcsCommands.loginCmd(mgrvo.getUsername(), mgrvo.getPassword());
                }
                else if(currentTime - cookieStartTime > COOKIE_REFRESH_TTL) {
                    cmd = UcsCommands.refreshCmd(mgrvo.getUsername(), mgrvo.getPassword(), cookie);
                }
            }
            if(cmd != null) {
                String ret = client.call(cmd);
                XmlObject xo = XmlObjectParser.parseFromString(ret);
                String cookie = xo.get("outCookie");
                ucsCookie = new UcsCookie(cookie, currentTime);
                cookies.put(ucsMgrId, ucsCookie);
                //cookiesTime.put(cookie, currentTime); //This is currentTime on purpose, and not latest time.
            }
            return ucsCookie.getCookie();
        } catch (Exception e) {
            throw new CloudRuntimeException("Cannot get cookie", e);
        }
    }
View Full Code Here

        }
    }

    private String getCookie(Long ucsMgrId) {
        try {
            UcsCookie ucsCookie = cookies.get(ucsMgrId);
            long currentTime = System.currentTimeMillis();
            UcsManagerVO mgrvo = ucsDao.findById(ucsMgrId);
            UcsHttpClient client = new UcsHttpClient(mgrvo.getUrl());
            String cmd = null;
            if (ucsCookie == null) {
                cmd = UcsCommands.loginCmd(mgrvo.getUsername(), mgrvo.getPassword());
            }
            else {
                String cookie = ucsCookie.getCookie();
                long cookieStartTime = ucsCookie.getStartTime();
                if(currentTime - cookieStartTime > COOKIE_TTL) {
                    cmd = UcsCommands.loginCmd(mgrvo.getUsername(), mgrvo.getPassword());
                }
                else if(currentTime - cookieStartTime > COOKIE_REFRESH_TTL) {
                    cmd = UcsCommands.refreshCmd(mgrvo.getUsername(), mgrvo.getPassword(), cookie);
                }
            }
            if(cmd != null) {
                String ret = client.call(cmd);
                XmlObject xo = XmlObjectParser.parseFromString(ret);
                String cookie = xo.get("outCookie");
                ucsCookie = new UcsCookie(cookie, currentTime);
                cookies.put(ucsMgrId, ucsCookie);
                //cookiesTime.put(cookie, currentTime); //This is currentTime on purpose, and not latest time.
            }
            return ucsCookie.getCookie();
        } catch (Exception e) {
            throw new CloudRuntimeException("Cannot get cookie", e);
        }
    }
View Full Code Here

TOP

Related Classes of com.cloud.ucs.structure.UcsCookie

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.