Determine the {@link UrlState} to use for the targeted portlet window
179558
protected UrlState determineUrlState(
            final IPortletWindow portletWindow,
            final IPortletUrlBuilder targetedPortletUrlBuilder) {
        final WindowState requestedWindowState;
        if (targetedPortletUrlBuilder == null) {
            requestedWindowState = null;
        } else {
            requestedWindowState = targetedPortletUrlBuilder.getWindowState();
        }

        return determineUrlState(portletWindow, requestedWindowState);
    }
971491
@Override
    public IPortalUrlBuilder getPortalUrlBuilderByPortletWindow(
            HttpServletRequest request, IPortletWindowId portletWindowId, UrlType urlType) {
        final IPortletWindow portletWindow =
                this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
        return getPortalUrlBuilderByPortletWindow(request, portletWindow, urlType);
    }
839504
public static URL toURL(String strUrl, int port, boolean encodeIfNecessary) throws MalformedURLException {
	URL url;
	try {
	    url = new URL(strUrl);
	}
	catch (MalformedURLException mue) {
	    url = new URL("http://" + strUrl);
	}
	if (!encodeIfNecessary) return url;
	return encodeURL(url, port);
    }
1173284
@RequestCache(keyMask = {false, true})
    @Override
    public String getFolderNameForPortlet(
            HttpServletRequest request, IPortletWindowId portletWindowId) {
        final IPortletWindow portletWindow =
                this.portletWindowRegistry.getPortletWindow(request, portletWindowId);
        final IPortletEntity portletEntity = portletWindow.getPortletEntity();
        final IPortletDefinition portletDefinition = portletEntity.getPortletDefinition();

        final String fname = portletDefinition.getFName();
        final String channelSubscribeId = portletEntity.getLayoutNodeId();

        // Build the targeted portlet string (fname + subscribeId)
        return fname + PORTLET_PATH_ELEMENT_SEPERATOR + channelSubscribeId;
    }
1094210
private <T> Observable<PollingState<T>> updateStateFromGetResourceOperationAsync(final PollingState<T> pollingState, String url) {
        return pollAsync(url, pollingState.loggingContext())
                .flatMap(new Func1<Response<ResponseBody>, Observable<PollingState<T>>>() {
                    @Override
                    public Observable<PollingState<T>> call(Response<ResponseBody> response) {
                        try {
                            pollingState.updateFromResponseOnPutPatch(response);
                            return Observable.just(pollingState);
                        } catch (CloudException | IOException e) {
                            return Observable.error(e);
                        }
                    }
                });
    }
465163
@Override
    public RelayState getState() {
        if(pin.isState(openState))
            return RelayState.OPEN;
        else
            return RelayState.CLOSED;
    }
734700
@Override
    public FetchStatus checkFilter(URI uri) {
        if (uri == null) {
            return FetchStatus.OUT_OF_SCOPE;
        }

        String otherScheme = normalisedScheme(uri.getRawScheme());
        if (port != normalisedPort(otherScheme, uri.getPort())) {
            return FetchStatus.OUT_OF_SCOPE;
        }

        if (!scheme.equals(otherScheme)) {
            return FetchStatus.OUT_OF_SCOPE;
        }

        if (!hasSameHost(uri)) {
            return FetchStatus.OUT_OF_SCOPE;
        }

        if (!startsWith(uri.getRawPath(), path)) {
            return FetchStatus.OUT_OF_SCOPE;
        }

        return FetchStatus.VALID;
    }
308296
@Override
    public IPortletWindowId getPortletForFolderName(
            HttpServletRequest request, String targetedLayoutNodeId, String folderName) {
        final IUserInstance userInstance = this.userInstanceManager.getUserInstance(request);

        final String fname;
        final IPortletEntity portletEntity;

        final int seperatorIndex = folderName.indexOf(PORTLET_PATH_ELEMENT_SEPERATOR);
        if (seperatorIndex <= 0 || seperatorIndex + 1 == folderName.length()) {
            fname = folderName;
            portletEntity =
                    this.portletEntityRegistry.getOrCreatePortletEntityByFname(
                            request, userInstance, fname);
        } else {
            fname = folderName.substring(0, seperatorIndex);
            final String subscribeId = folderName.substring(seperatorIndex + 1);

            portletEntity =
                    this.portletEntityRegistry.getOrCreatePortletEntityByFname(
                            request, userInstance, fname, subscribeId);
        }
        if (portletEntity != null) {
            final IPortletEntityId portletEntityId = portletEntity.getPortletEntityId();
            final IPortletWindow portletWindow =
                    this.portletWindowRegistry.getOrCreateDefaultPortletWindow(
                            request, portletEntityId);
            return portletWindow.getPortletWindowId();
        } else {
            this.logger.warn(
                    targetedLayoutNodeId
                            + " node for portlet of folder "
                            + folderName
                            + " can't be targeted by the request.");
            return null;
        }
    }
181634
@Override
    public boolean isPortletRenderHeaderRequested(
            IPortletWindowId portletWindowId,
            HttpServletRequest request,
            HttpServletResponse response) {
        final Map<IPortletWindowId, IPortletRenderExecutionWorker> portletRenderingMap =
                this.getPortletHeaderRenderingMap(request);
        final IPortletRenderExecutionWorker tracker = portletRenderingMap.get(portletWindowId);

        return tracker != null;
    }
182498
public static void setStateParam(String name, String value, HttpServletRequest req,
			HttpServletResponse res, boolean httpOnly) {
		setRawCookie(name, value, req, res, httpOnly, -1);
	}
574966
function (fragment, urlRoot) {
            return location.protocol + '//' + location.host + this.removeEndSlash(urlRoot) + this.addStartSlash(fragment);
        }
644138
function(url) {
            if (url == null) return this;
            if (url.length > 0 && url[0] == "/") {
                url = url.replace("/", "");
            }
            var matched = _.any(this.handlers, function(handler) {
                if (handler.route.test(url)) {
                    handler.callback(url);
                    return true;
                }
                return false;
            });
            logging.log("handle state ", url, matched != null);
            return matched;
        }
678493
protected String getResultUrl(
            HttpServletRequest httpServletRequest,
            SearchResult result,
            IPortletWindowId portletWindowId) {
        final String externalUrl = result.getExternalUrl();
        if (externalUrl != null) {
            return externalUrl;
        }

        UrlType urlType = UrlType.RENDER;

        final PortletUrl portletUrl = result.getPortletUrl();
        if (portletUrl != null) {
            final PortletUrlType type = portletUrl.getType();
            if (type != null) {
                switch (type) {
                    case ACTION:
                        {
                            urlType = UrlType.ACTION;
                            break;
                        }
                    default:
                    case RENDER:
                        {
                            urlType = UrlType.RENDER;
                            break;
                        }
                    case RESOURCE:
                        {
                            urlType = UrlType.RESOURCE;
                            break;
                        }
                }
            }
        }

        final IPortalUrlBuilder portalUrlBuilder =
                this.portalUrlProvider.getPortalUrlBuilderByPortletWindow(
                        httpServletRequest, portletWindowId, urlType);
        final IPortletUrlBuilder portletUrlBuilder =
                portalUrlBuilder.getTargetedPortletUrlBuilder();

        if (portletUrl != null) {
            final String portletMode = portletUrl.getPortletMode();
            if (portletMode != null) {
                portletUrlBuilder.setPortletMode(PortletUtils.getPortletMode(portletMode));
            }
            final String windowState = portletUrl.getWindowState();
            if (windowState != null) {
                portletUrlBuilder.setWindowState(PortletUtils.getWindowState(windowState));
            }
            for (final PortletUrlParameter param : portletUrl.getParam()) {
                final String name = param.getName();
                final List<String> values = param.getValue();
                portletUrlBuilder.addParameter(name, values.toArray(new String[values.size()]));
            }
        }

        return portalUrlBuilder.getUrlString();
    }
783072
function(state) {
      return state.url ? state : (state.parent ? state.parent.navigable : null);
    }
435503
@Override
    public String getPortletTitle(
            IPortletWindowId portletWindowId,
            HttpServletRequest request,
            HttpServletResponse response) {
        final IPortletDefinition portletDefinition = getPortletDefinition(portletWindowId, request);
        final IPortletDefinitionParameter disableDynamicTitle =
                portletDefinition.getParameter("disableDynamicTitle");

        if (disableDynamicTitle == null || !Boolean.parseBoolean(disableDynamicTitle.getValue())) {
            try {
                final PortletRenderResult portletRenderResult =
                        getPortletRenderResult(portletWindowId, request, response);
                if (portletRenderResult != null) {
                    final String title = portletRenderResult.getTitle();
                    if (title != null) {
                        return title;
                    }
                }
            } catch (Exception e) {
                logger.warn(
                        "unable to get portlet title, falling back to title defined in channel definition for portletWindowId "
                                + portletWindowId);
            }
        }

        // we assume that response locale has been set to correct value
        String locale = response.getLocale().toString();

        // return portlet title from channel definition
        return portletDefinition.getTitle(locale);
    }
365438
@Nullable
  public static String getURLValue (@Nullable final String sValue)
  {
    if (isURLValue (sValue))
    {
      return CSSParseHelper.trimUrl (sValue);
    }
    return null;
  }
503199
function(url) {
		if (url.match(/^http/i)) {
			return url;
		}
		if (url.substr(0,2) === '//') {
			return window.location.protocol + url;
		}
		var root = window.location.protocol + '//' + window.location.host,
			reg  = /[^\/]+\/\.\.\//,
			ret;
		if (url.substr(0, 1) === '/') {
			ret = root + url;
		} else {
			ret = root + window.location.pathname.replace(/\/[^\/]+$/, '/') + url;
		}
		ret = ret.replace('/./', '/');
		while(reg.test(ret)) {
			ret = ret.replace(reg, '');
		}
		return ret;
	}