⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 portleturlimpl.java

📁 GridSphere 门户 提供一个基于 portlet 的高级开放源代码门户。GridSphere 是在欧盟提供基金的 GridLab 项目下开发的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        this.store = new HashMap<String, Object>();        for (Object key : parameters.keySet()) {            if (key == null) throw new IllegalArgumentException("a parameters key is NULL");            if (key instanceof String) {                Object values = parameters.get(key);                if (values == null) throw new IllegalArgumentException("a parameters value is NULL");                if (!(values instanceof String[])) {                    throw new IllegalArgumentException("a parameters value element must be a string array");                }                this.setParameter((String) key, (String[]) values);            } else {                throw new IllegalArgumentException("parameter key must be a string");            }        }    }    public void setAction(String action) {        store.put(SportletProperties.DEFAULT_PORTLET_ACTION, action);    }    public void setRender(String render) {        store.put(SportletProperties.DEFAULT_PORTLET_RENDER, render);    }    /**     * Sets a label for this link, which will overwrite the component id     *     * @param label the link label     */    public void setLabel(String label) {        this.label = label;    }    /**     * Sets the layout id that identifies a layout descriptor to target     *     * @param layout the layout id that identifies a layout descriptor to target     */    public void setLayout(String layout) {        this.layout = layout;    }    /**     * Indicated the security setting for this URL.     * <p/>     * Secure set to <code>true</code> indicates that the portlet requests     * a secure connection between the client and the portlet window for     * this URL. Secure set to <code>false</code> indicates that the portlet     * does not need a secure connection for this URL. If the security is not     * set for a URL, it will stay the same as the current request.     *     * @param secure true, if portlet requests to have a secure connection     *               between its portlet window and the client; false, if     *               the portlet does not require a secure connection.     * @throws PortletSecurityException if the run-time environment does     *                                  not support the indicated setting     */    public void setSecure(boolean secure) throws PortletSecurityException {        this.isSecure = secure;    }    public void setEncoding(boolean encoding) {        this.encoding = encoding;    }    public boolean isEncoding() {        return encoding;    }    /**     * Returns the portlet URL string representation to be embedded in the     * markup.<br>     * Note that the returned String may not be a valid URL, as it may     * be rewritten by the portal/portlet-container before returning the     * markup to the client.     *     * @return the encoded URL as a string     */    public String toString() {        StringBuffer s = new StringBuffer();        String port = null;        if (req.isSecure() || isSecure || (req.getAttribute(SportletProperties.SSL_REQUIRED) != null)) {            s.append("https://");            port = configService.getProperty(PortalConfigService.PORTAL_SECURE_PORT);        } else {            s.append("http://");            port = configService.getProperty(PortalConfigService.PORTAL_PORT);        }        String hostname = configService.getProperty(PortalConfigService.PORTAL_HOST);        if (hostname == null || hostname.equals("")) hostname = req.getServerName();        s.append(hostname);        if (!port.equals("80") && (!port.equals("443"))) {            s.append(":");            s.append((!port.equals("")) ? port : String.valueOf(req.getServerPort()));        }        // if underlying window state is floating then set it in the URI        if (req.getAttribute(SportletProperties.FLOAT_STATE) != null) {            store.put(SportletProperties.PORTLET_WINDOW, "FLOATING");        }        String contextPath = "/" + configService.getProperty("gridsphere.deploy");        // handle ROOT context        if (contextPath.equals("/")) contextPath = "";        String servletPath = "/" + configService.getProperty("gridsphere.context");        //String servletPath = req.getServletPath();        String url = contextPath + servletPath;        String cid = (String) req.getAttribute(SportletProperties.COMPONENT_ID);        /*          This bit of jiggery is here only for the LayoutManager portlet currently.          A special param SportletProperties.EXTRA_QUERY_INFO can be used to stuff          some extra params into every portal generated url         */        String extraQuery = (String) req.getAttribute(SportletProperties.EXTRA_QUERY_INFO);        if (extraQuery != null) {            StringTokenizer st = new StringTokenizer(extraQuery, "&");            while (st.hasMoreTokens()) {                String cmd = (String) st.nextElement();                //System.err.println("cmd= " + cmd);                if (cmd.startsWith(SportletProperties.COMPONENT_ID)) {                    store.put(SportletProperties.COMPONENT_ID_2, cid);                    cid = cmd.substring(SportletProperties.COMPONENT_ID.length() + 1);                } else if (cmd.startsWith(SportletProperties.DEFAULT_PORTLET_ACTION)) {                    String action = (String) store.get(SportletProperties.DEFAULT_PORTLET_ACTION);                    store.put(SportletProperties.DEFAULT_PORTLET_ACTION_2, action);                    store.put(SportletProperties.DEFAULT_PORTLET_ACTION, cmd.substring(SportletProperties.DEFAULT_PORTLET_ACTION.length() + 1));                }            }        }        String layoutId = layout;        if (layoutId == null) {            layoutId = (String) req.getAttribute(SportletProperties.LAYOUT_PAGE);        }        if (layoutId != null) {            //System.err.println("layoutId=" + layoutId);            url += "/" + layoutId;            //String compVar = (String)req.getAttribute(SportletProperties.COMPONENT_ID_VAR);            //if (compVar == null) compVar = SportletProperties.COMPONENT_ID;            /*             // if a label exists, use it instead            if (label != null) {                cid = label;            } else{                cid = (String)req.getAttribute(SportletProperties.COMPONENT_ID);            }            */            // if a label exists, use it instead            if (label != null) cid = label;            if (cid != null) {                url += "/" + cid;                if (mode != null) url += "/m/" + mode.toString();                if (state != null) url += "/s/" + state.toString();                String action = (String) store.get(SportletProperties.DEFAULT_PORTLET_ACTION);                if (action != null) {                    store.remove(SportletProperties.DEFAULT_PORTLET_ACTION);                    url += "/a/" + action;                }                String render = (String) store.get(SportletProperties.DEFAULT_PORTLET_RENDER);                if (render != null) {                    store.remove(SportletProperties.DEFAULT_PORTLET_RENDER);                    url += "/r/" + render;                }            }            //System.err.println("url=" + layoutId);        }        ///////////// JASON ADDED ABOVE        Set set = store.keySet();        if (!set.isEmpty()) {            // add question mark            url += "?";            Iterator it = set.iterator();            boolean firstParam = true;            try {                while (it.hasNext()) {                    if (!firstParam) url += "&";                    String name = (String) it.next();                    String encname = null;                    encname = URLEncoder.encode(name, "UTF-8");                    Object val = store.get(name);                    if (val instanceof String[]) {                        String[] vals = (String[]) val;                        for (int j = 0; j < vals.length - 1; j++) {                            String encvalue = URLEncoder.encode(vals[j], "UTF-8");                            url += encname + "=" + encvalue + "&";                        }                        String encvalue = URLEncoder.encode(vals[vals.length - 1], "UTF-8");                        url += encname + "=" + encvalue;                    } else if (val instanceof String) {                        String aval = (String) store.get(name);                        if ((aval != null) && (!aval.equals(""))) {                            String encvalue = URLEncoder.encode(aval, "UTF-8");                            url += encname + "=" + encvalue;                        } else {                            url += encname;                        }                    }                    firstParam = false;                }            } catch (UnsupportedEncodingException e) {                System.err.println("Unable to support UTF-8 encoding!");            }            if (encoding) {                if (redirect) {                    url = res.encodeRedirectURL(url);                } else {                    url = res.encodeURL(url);                }            }        }        s.append(url);        //System.err.println("created URL= " + s.toString());        return s.toString();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -