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

📄 baseurlimpl.java

📁 portal越来越流行了
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	    }
	    else if (isResourceServing){
	    	urlProvider.setResourceServing(true);
	    }
        PortletApplicationDefinition portletAppDD = portletWindow.getPortletEntity().getPortletDefinition().getApplication();  
//      container.getOptionalContainerServices().getPortletRegistryService().getRegisteredPortletApplications()
//      PortletAppDD portletAppDD = container.getPortletApplicationDescriptor(  );
        portletURLFilterListener.callListener(portletAppDD,this,isAction,isResourceServing);
	    
        if (secure && urlProvider.isSecureSupported()) {
            try {
                urlProvider.setSecure();
            } catch (PortletSecurityException e) {
                throw new IllegalStateException("URL Provider is misconfigured." +
                    "  It claims to support secure urls," +
                    " yet it threw a PortletSecurityException");
            }
	    }
	    if (!isResourceServing)
	    	urlProvider.clearParameters();
	    
			
	    urlProvider.setParameters(parameters);
	    
	    urlProvider.setPublicRenderParameters(publicRenderParameters);
	    
	    return urlProvider.toString();
	}
	// --------------------------------------------------------------------------------------------

	public String getParameter(String name) {
	    return (String) parameters.get(name);
	}

	public String[] getParameters(String name) {
	    return (String[]) parameters.get(name);
	}
	
	public Map getParameterMap() {
		return parameters;
	}

	public PortletMode getPortletMode() {
	    return mode;
	}

	public WindowState getWindowState() {
	    return state;
	}
	// --------------------------------------------------------------------------------------------

	protected boolean isPortletModeAllowed(PortletMode mode) throws PortletModeException {
	    if (mode == null) {
	        throw new PortletModeException(
	            EXCEPTIONS.getString("javax.portlet.PortletModeException.null"),
	            null);
	    }
	
	    return isPortletModeAllowedByPortlet(mode)
	           && isPortletModeAllowedByPortal(mode);
	}

	private boolean isPortletModeAllowedByPortlet(PortletMode mode) throws PortletModeException {
	    // PLT 8.1: View Portlet Mode should always be
	    // supported by a portlet, even if not defined in the descriptor
	    if (mode.equals(PortletMode.VIEW)) {
	        return true;
	    }
	
	    PortletDefinition dd = portletWindow.getPortletEntity()
	        .getPortletDefinition();
	    Iterator supports = dd.getSupports().iterator();
	    while(supports.hasNext()) {
	        Supports support = (Supports)supports.next();
	        if (support.getPortletModes() != null){
	        	Iterator modes = support.getPortletModes().iterator();
		        while(modes.hasNext()) {
		            String md = (String)modes.next();
		            if (md.toUpperCase().equals(
		                mode.toString().toUpperCase())) {
		                return true;
		            }
		        }
	        }
	    }
	    String message = EXCEPTIONS.getString(
	        "javax.portlet.PortletModeException.portlet", mode.toString());
	
	    throw new PortletModeException(message, mode);
	}

	private boolean isPortletModeAllowedByPortal(PortletMode mode) throws PortletModeException {
	    Enumeration supportedModes = context.getSupportedPortletModes();
	    while (supportedModes.hasMoreElements()) {
	        if (supportedModes.nextElement().toString().toUpperCase().equals(
	            (mode.toString().toUpperCase()))) {
	            return true;
	        }
	    }
	    String message = EXCEPTIONS.getString(
	        "javax.portlet.PortletModeException.portal", mode.toString());
	
	    throw new PortletModeException(message, mode);
	}

	protected boolean isWindowStateAllowed(WindowState state) {
	    Enumeration supportedStates = context.getSupportedWindowStates();
	    while (supportedStates.hasMoreElements()) {
	        if (supportedStates.nextElement().toString().toUpperCase().equals(
	            (state.toString().toUpperCase()))) {
	            return true;
	        }
	    }
	    return false;
	}

	public void write(Writer out) throws IOException {
		
	    PortletURLProvider urlProvider = container
	    		.getRequiredContainerServices()
	    		.getPortalCallbackService()
	    		.getPortletURLProvider(servletRequest, portletWindow);
	
	    PortletURLListener portletURLFilterListener = portletURLFilterListener = container
			.getRequiredContainerServices()
			.getPortalCallbackService().getPortletURLListener();
	    if (mode != null) {
	        urlProvider.setPortletMode(mode);
	    }
	    if (state != null) {
	        urlProvider.setWindowState(state);
	    }
	    if (isAction) {
	        urlProvider.setAction(true);
	    }
	    else if (isResourceServing){
	    	urlProvider.setResourceServing(true);
	    }
        PortletApplicationDefinition portletAppDD = portletWindow.getPortletEntity().getPortletDefinition().getApplication();  
//      container.getOptionalContainerServices().getPortletRegistryService().getRegisteredPortletApplications()
//      PortletAppDD portletAppDD = container.getPortletApplicationDescriptor(  );
        portletURLFilterListener.callListener(portletAppDD,this,isAction,isResourceServing);
	    
        if (secure && urlProvider.isSecureSupported()) {
            try {
                urlProvider.setSecure();
            } catch (PortletSecurityException e) {
                throw new IllegalStateException("URL Provider is misconfigured." +
                    "  It claims to support secure urls," +
                    " yet it threw a PortletSecurityException");
            }
	    }
	    if (!isResourceServing)
	    	urlProvider.clearParameters();
	    
			
	    urlProvider.setParameters(parameters);
	    
	    urlProvider.setPublicRenderParameters(publicRenderParameters);
	    
	    out.write(urlProvider.toString());
	}

	public void write(Writer out, boolean escapeXML) throws IOException {
		this.escapeXML = escapeXML;
		write(out);
	}

	public void addProperty(String key, String value) {
		container.getRequiredContainerServices().getPortalCallbackService().getRequestPropertyProvider().addProperty(servletRequest, portletWindow, key, value);
		
	}

	public void setProperty(String key, String value) {
		container.getRequiredContainerServices().getPortalCallbackService().getRequestPropertyProvider().setProperty(servletRequest, portletWindow, key, value);
		
	}

	//TODO:This two methods should be deleted, when the CACHABILITY parameter gets his own prefix
	private String[] getRenderParameters(String name){
		int lenght = 0;
		String[] tmp1 = this.servletRequest.getParameterValues(name);
		if (tmp1!=null)
			lenght += tmp1.length;
		PortletURLProvider urlProvider = container.getRequiredContainerServices().getPortalCallbackService().getPortletURLProvider(servletRequest, portletWindow);
		String[] tmp2 = urlProvider.getPrivateRenderParameters(name);
		if (tmp2!=null)
			lenght += tmp2.length;
		String[] tmp3 = urlProvider.getPublicRenderParameters(name);
		if (tmp3!=null)
			lenght += tmp3.length;
		if (lenght>0){
			String[] values = new String[lenght];
			int pos = mergeStrings(tmp1, values, 0);
			pos = mergeStrings(tmp2, values, pos);
			mergeStrings(tmp3, values, pos);
			return values;
		}
		return null;
	}
	private int mergeStrings(String[] src, String[] destination, int position){
		if (src == null)
			return position;
		System.arraycopy(src, 0, destination, position, src.length);
		return position+src.length;
	}
}

⌨️ 快捷键说明

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