Return the redirect destination of according to wikimedia syntax.

@param pageText Must not be {@code null}.
@return redirect destination
358810
public static String getRedirectDestination(String pageText) {
		String redirectString = null;
		try {
			String regex = "\\[\\[\\s*(.+?)\\s*]]";
			Pattern pattern = Pattern.compile(regex);
			Matcher matcher = pattern.matcher(pageText);

			// group 0 is the whole match
			if (matcher.find()) {
				redirectString = matcher.group(1);
			}
			if (redirectString == null) {
				return null;
			}

			// remove anchor (case: "#Redirect [[Article #Anchor]])
			String[] anchorSplitValues = redirectString.split("#");
			redirectString = anchorSplitValues[0];
			// remove whitespace (case: "Article " - when splitting the example
			// above)
			redirectString = redirectString.trim();

			// remove direct|redirect alternatives
			String[] directSplitValues = redirectString.split("\\|");
			redirectString = directSplitValues[0];
			// remove whitespace (case: "Article " - when splitting the example
			// above)
			redirectString = redirectString.trim();

			// remove whitespace (case: "Article " - when splitting the example
			// above)
			redirectString = redirectString.trim();

			// remove namespace string (case:
			// "#REDIRECT [[Portal:Recht/Liste der Rechtsthemen]]")
			// but there are names with colons in it => consider only cases
			// where
			// there are no spaces around the colon
			String regexNamespace = ":([^\\s].+)";
			Pattern patternNamespace = Pattern.compile(regexNamespace);
			Matcher matcherNamespace = patternNamespace.matcher(redirectString);

			// group 0 is the whole match
			if (matcherNamespace.find()) {
				redirectString = matcherNamespace.group(1);
			}

			// replace spaces with underscores (spaces are represented as
			// underscores in page titles)
			// e.g. "Englische Grammatik"
			redirectString = redirectString.replace(" ", "_");

			// page titles always start with a capital letter
			if (redirectString.length() > 0) {
				redirectString = redirectString.substring(0, 1).toUpperCase()
						+ redirectString.substring(1, redirectString.length());
			}
		} catch (Exception e) {
			redirectString = null;
			logger.debug("Error in Redirects ignored");
		}

		return redirectString;
	}
172236
private static Page findPage(
		ServletContext servletContext,
		HttpServletRequest req,
		HttpServletResponse resp,
		SemanticCMS semanticCMS
	) throws ServletException, IOException {
		// Path extra info not allowed
		if(req.getPathInfo() != null) {
			return null;
		}
		// Query string not allowed
		if(req.getQueryString() != null) {
			return null;
		}
		String basePath;
		{
			String servletPath = req.getServletPath();
			// Must end in expected extension
			if(!servletPath.endsWith(RssUtils.EXTENSION)) {
				return null;
			}
			basePath = servletPath.substring(0, servletPath.length() - RssUtils.EXTENSION.length());
		}
		// Try to find the page, jspx, then jsp, then direct URL without extension
		String pagePath = null;
		for (String extension : RssUtils.getResourceExtensions()) {
			pagePath = basePath + extension;
			try {
				if(
					!RssUtils.isProtectedExtension(pagePath)
					&& ServletContextCache.getResource(servletContext, pagePath) != null
				) {
					break;
				}
			} catch(MalformedURLException e) {
				// Assume does not exist
			}
		}
		assert pagePath != null : "The last extension should be the default if none matched";
		if(RssUtils.isProtectedExtension(pagePath)) {
			return null;
		}
		// Find book and path
		PageRef pageRef;
		{
			Book book = semanticCMS.getPublishedBook(pagePath);
			if(book == null || !book.isAccessible()) {
				return null;
			}
			BookRef bookRef = book.getBookRef();
			try {
				pageRef = new PageRef(
					bookRef,
					Path.valueOf(pagePath.substring(bookRef.getPrefix().length()))
				);
			} catch(ValidationException e) {
				return null;
			}
		}
		// Capture the page
		return CapturePage.capturePage(
			servletContext,
			req,
			resp,
			pageRef,
			CaptureLevel.META
		);
	}
902705
public static Page getPage(TagSupport tag, PageContext context,
			String strPage, int iLevel) {
		Page page = null;

		SiteContext sc = (SiteContext) context.getRequest().getAttribute(
				SiteContext.SITE_CONTEXT_KEY);
		AuthorizationEngine ap = ContextUtils
				.getAuthorizationEngine((HttpServletRequest) context
						.getRequest());

		if (strPage != null) {
			if (strPage.equals("AE_ROOT"))
				page = sc.getBranch().getHome(ap);
			else if (strPage.equals("AE_CURRENT"))
				page = sc.getPage();
			else
				page = (Page) context.getAttribute(strPage);
		} else if (iLevel >= 0) {
			Page currentInTree = sc.getPage();
			if (iLevel <= currentInTree.getLevel()) {
				page = currentInTree;
				while (iLevel < page.getLevel())
					page = page.getParent();
			}
		} else {
			TreeTag tt = (TreeTag) TagSupport.findAncestorWithClass(tag,
					TreeTag.class);
			if (tt != null)
				page = tt.getPage();
			else {
				PathTag pt = (PathTag) TagSupport.findAncestorWithClass(tag,
						PathTag.class);
				if (pt != null)
					page = pt.getPage();
			}
		}

		if (page == null)
			page = sc.getPage();

		return page;
	}
601497
public String getContextPath() {
        ServletRequest request = pageContext.getRequest();
        if (request instanceof HttpServletRequest) {
            return ((HttpServletRequest) request).getContextPath();
        }
        return "/";
    }
930713
public void redirect(String location, int httpStatusCode) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Redirecting ({} to {}", httpStatusCode, location);
        }
        response.setStatus(httpStatusCode);
        response.setHeader("Location", location);
        response.setHeader("Connection", "close");
        try {
            response.sendError(httpStatusCode);
        } catch (IOException e) {
            LOG.warn("Exception when trying to redirect permanently", e);
        }
    }
1346016
@Override
    @SuppressWarnings("checkstyle:linelength")
    public Page<AvailablePhoneNumberCountry> getPage(final String targetUrl, final TwilioRestClient client) {
        this.pathAccountSid = this.pathAccountSid == null ? client.getAccountSid() : this.pathAccountSid;
        Request request = new Request(
            HttpMethod.GET,
            targetUrl
        );

        return pageForRequest(client, request);
    }
859252
protected PageContext getPageContext()
    {
        JspContext ctxt = getJspContext();
        if (ctxt instanceof PageContext)
            return (PageContext) ctxt;

        // assert the page context and log an error in production
        assert(false) : "The JspContext was not a PageContext";
        logger.error("The JspContext was not a PageContext");
        return null;
    }
679177
@XmlElement(name = "lastPageLink")
    @JsonProperty(value = "lastPageLink")
    @ApiModelProperty(value = "The last pagination link.", position = 5)
    public PageRequestLinkDto getLastPageLink() {
        return lastPageLink;
    }
42362
@Override
    public void sendRedirect(String location) throws IOException {
        if (isCommitted()) {
            throw new IllegalStateException("Response already committed");
        }
        if (null == location) {
            throw new IllegalArgumentException("Location is null");
        }
        resetBuffer();
        this.response.setHeader("Location", convertURItoURL(location.trim()));
        this.response.setStatus(307);
        flushBuffer();
    }
1343087
private String getRedirectUrl(RequestParametersHolder requestHolder) throws AlipayApiException {
        StringBuffer urlSb = new StringBuffer(serverUrl);
        try {
            Map<String, String> sortedMap = AlipaySignature.getSortedMap(requestHolder);
            String sortedQuery = WebUtils.buildQuery(sortedMap, charset);
            urlSb.append("?");
            urlSb.append(sortedQuery);
        } catch (IOException e) {
            throw new AlipayApiException(e);
        }

        return urlSb.toString();
    }
1333290
public static PageRequestDto createPageRequestDto(final PageRequest pageRequest) {
        final PageRequestDto pageRequestDto;
        if (pageRequest == null) {
            pageRequestDto = null;
        } else if (pageRequest instanceof PageRequestDto) {
            pageRequestDto = (PageRequestDto) pageRequest;
        } else {
            pageRequestDto = new PageRequestDto(pageRequest);
        }
        return pageRequestDto;
    }
7280
protected function _calculateRedirection(EntityInterface $content)
    {
        foreach (['translation', 'parent'] as $method) {
            if ($has = $content->{$method}()) {
                return option('url_locale_prefix') ? '/' . $has->get('language') . stripLanguagePrefix($has->get('url')) : $has->get('url');
            }
        }

        return '';
    }
735463
public void sendRedirect(String location) throws IOException {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {  //306998.15
            logger.entering(CLASS_NAME,"sendRedirect", "location --> " + PasswordNullifier.nullifyParams(location) + " ["+this+"]" );
        }

        // d151464 - check the include flag
        WebAppDispatcherContext dispatchContext = (WebAppDispatcherContext) getRequest().getWebAppDispatcherContext();
        if (dispatchContext.isInclude() == true) {
            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {  //306998.15
                logger.logp(Level.FINE, CLASS_NAME,"sendRedirect", nls.getString("Illegal.from.included.servlet", "Illegal from included servlet"), "sendRedirect location --> " + PasswordNullifier.nullifyParams(location));  //311717
            }
        }
        else {
            dispatchContext.sendRedirect(location);
        }

        this.closeResponseOutput();

        // PK79143 Start
        if (!isCommitted() && !dispatchContext.isInclude()) {                                          // PM04383
            if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE))
                logger.logp(Level.FINE, CLASS_NAME,"sendRedirect"," : Not committed, so write headers");
            commit();
            _response.setLastBuffer(true);
            _response.writeHeaders();
        }
        // PK79143 End

        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {  //306998.15
            logger.exiting(CLASS_NAME,"sendRedirect");
        }        
    }
1298314
public Title getTitle(int pageId) throws WikiApiException {
    	Session session = this.__getHibernateSession();
        session.beginTransaction();
        Object returnValue = session.createNativeQuery(
            "select p.name from PageMapLine as p where p.pageId= :pId").setParameter("pId", pageId, IntegerType.INSTANCE).uniqueResult();
        session.getTransaction().commit();

        String title = (String)returnValue;
        if(title==null){
        	throw new WikiPageNotFoundException();
        }
        return new Title(title);
    }
454813
public static PageContext getPageContext(JspContext jspContext) {
        if(!(jspContext instanceof PageContext))
            throw new IllegalStateException(Bundle.getErrorString("DataGridUtil_IllegalJspContext", new Object[]{(jspContext != null ? jspContext.getClass().getName() : "null")}));
        else
            return (PageContext)jspContext;
    }
560810
public static ExpressionFactory getExpressionFactory(PageContext pageContext) {
        JspApplicationContext appContext = JspFactory.getDefaultFactory().getJspApplicationContext(pageContext.getServletContext());
        return appContext.getExpressionFactory();
    }
250434
@SuppressWarnings("static-method")
	protected ReferenceContext extractReferencableElements(String text) {
		final ReferenceContext context = new ReferenceContext();

		// Visit the links and record the transformations
		final MutableDataSet options = new MutableDataSet();
		final Parser parser = Parser.builder(options).build();
		final Node document = parser.parse(text);
		final Pattern pattern = Pattern.compile(SECTION_PATTERN_AUTONUMBERING);
		NodeVisitor visitor = new NodeVisitor(
				new VisitHandler<>(Paragraph.class, it -> {
					final Matcher matcher = pattern.matcher(it.getContentChars());
					if (matcher.find()) {
						final String number = matcher.group(2);
						final String title = matcher.group(3);
						final String key1 = computeHeaderId(number, title);
						final String key2 = computeHeaderId(null, title);
						context.registerSection(key1, key2, title);
					}
				}));
		visitor.visitChildren(document);

		visitor = new NodeVisitor(
				new VisitHandler<>(Heading.class, it -> {
					String key = it.getAnchorRefId();
					final String title = it.getAnchorRefText();
					final String key2 = computeHeaderId(null, title);
					if (Strings.isEmpty(key)) {
						key = key2;
					}
					context.registerSection(key, key2, title);
				}));
		visitor.visitChildren(document);

		return context;
	}