org.apache.wicket.request.http.WebRequest Java Examples

The following examples show how to use org.apache.wicket.request.http.WebRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PullRequestActivitiesPage.java    From onedev with MIT License 6 votes vote down vote up
public PullRequestActivitiesPage(PageParameters params) {
	super(params);

	WebRequest request = (WebRequest) RequestCycle.get().getRequest();
	Cookie cookie = request.getCookie(COOKIE_SHOW_COMMENTS);
	if (cookie != null)
		showComments = Boolean.valueOf(cookie.getValue());
	
	cookie = request.getCookie(COOKIE_SHOW_COMMITS);
	if (cookie != null)
		showCommits = Boolean.valueOf(cookie.getValue());
	
	cookie = request.getCookie(COOKIE_SHOW_CHANGE_HISTORY);
	if (cookie != null)
		showChangeHistory = Boolean.valueOf(cookie.getValue());
}
 
Example #2
Source File: LoginPage.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
public static void logout(final MySession mySession, final WebRequest request, final WebResponse response,
    final UserXmlPreferencesCache userXmlPreferencesCache, final MenuBuilder menuBuilder)
{
  final PFUserDO user = mySession.getUser();
  if (user != null) {
    userXmlPreferencesCache.flushToDB(user.getId());
    userXmlPreferencesCache.clear(user.getId());
    if (menuBuilder != null) {
      menuBuilder.expireMenu(user.getId());
    }
  }
  mySession.logout();
  final Cookie stayLoggedInCookie = UserFilter.getStayLoggedInCookie(WicketUtils.getHttpServletRequest(request));
  if (stayLoggedInCookie != null) {
    stayLoggedInCookie.setMaxAge(0);
    stayLoggedInCookie.setValue(null);
    stayLoggedInCookie.setPath("/");
    response.addCookie(stayLoggedInCookie);
  }
}
 
Example #3
Source File: OWebEnhancer.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
public OLoggerEvent enhance(OLoggerEvent event) {
	RequestCycle cycle = RequestCycle.get();

	if (cycle != null) {
		OrienteerWebSession session = OrienteerWebSession.get();
		if (session != null) {
			if (session.isClientInfoAvailable()) {
				WebClientInfo clientInfo = session.getClientInfo();
				event.setMetaData(OLoggerEventModel.PROP_REMOTE_ADDRESS, clientInfo.getProperties().getRemoteAddress());
				event.setMetaData(OLoggerEventModel.PROP_HOST_NAME, clientInfo.getProperties().getHostname());
			}
			if(session.isSignedIn()) {
				event.setMetaData(OLoggerEventModel.PROP_USERNAME, session.getEffectiveUser().getName());
			}
		}

		WebRequest request = (WebRequest)cycle.getRequest();
		event.setMetaData(OLoggerEventModel.PROP_CLIENT_URL, request.getClientUrl());
	}
	return event;
}
 
Example #4
Source File: LazyAuthorizationRequestCycleListener.java    From wicket-orientdb with Apache License 2.0 6 votes vote down vote up
@Override
public void onBeginRequest(RequestCycle cycle) {
	WebRequest request = (WebRequest) cycle.getRequest();
	String authorization = request.getHeader(AUTHORIZATION_HEADER);
	if(authorization!=null && authorization.startsWith("Basic"))
	{
		String[] pair = new String(Base64.getDecoder().decode(authorization.substring(6).trim())).split(":"); 
           if (pair.length == 2) { 
               String userName = pair[0]; 
               String password = pair[1]; 
               OrientDbWebSession session = OrientDbWebSession.get();
               if(!session.signIn(userName, password))
               {
               	cycle.setMetaData(LAZY_AUTHORIZED, false);
               }
           }
	}
}
 
Example #5
Source File: ToDoApplication.java    From isis-app-todoapp with Apache License 2.0 6 votes vote down vote up
@Override
public WebRequest newWebRequest(final HttpServletRequest servletRequest, final String filterPath) {
    if(!DEMO_MODE_USING_CREDENTIALS_AS_QUERYARGS) {
        return super.newWebRequest(servletRequest, filterPath);
    } 

    // else demo mode
    try {
        final String uname = servletRequest.getParameter("user");
        if (uname != null) {
            servletRequest.getSession().invalidate();
        }
    } catch (Exception ignored) {
    }

    return super.newWebRequest(servletRequest, filterPath);
}
 
Example #6
Source File: OneWebApplication.java    From onedev with MIT License 6 votes vote down vote up
@Override
public WebRequest newWebRequest(HttpServletRequest servletRequest, String filterPath) {
	return new ServletWebRequest(servletRequest, filterPath) {

		@Override
		public boolean shouldPreserveClientUrl() {
			if (RequestCycle.get().getActiveRequestHandler() instanceof RenderPageRequestHandler) {
				RenderPageRequestHandler requestHandler = 
						(RenderPageRequestHandler) RequestCycle.get().getActiveRequestHandler();
				
				/*
				 *  Add this to make sure that the page url does not change upon errors, so that 
				 *  user can know which page is actually causing the error. This behavior is common
				 *  for main stream applications.   
				 */
				if (requestHandler.getPage() instanceof GeneralErrorPage) 
					return true;
			}
			return super.shouldPreserveClientUrl();
		}
		
	};
}
 
Example #7
Source File: SideBar.java    From onedev with MIT License 6 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(newHead("head"));
	add(new Tabbable("tabs", newTabs()));
	add(new WebMarkupContainer("miniToggle").setVisible(miniCookieKey!=null));

	add(AttributeAppender.append("class", "sidebar"));
	
	if (miniCookieKey != null) {
		add(AttributeAppender.append("class", "minimizable"));
		WebRequest request = (WebRequest) RequestCycle.get().getRequest();
		Cookie miniCookie = request.getCookie(miniCookieKey);
		if (miniCookie != null) {
			if ("yes".equals(miniCookie.getValue()))
				add(AttributeAppender.append("class", "minimized"));
		} else if (WicketUtils.isDevice()) {
			add(AttributeAppender.append("class", "minimized"));
		}
	} 
}
 
Example #8
Source File: MarkdownEditor.java    From onedev with MIT License 6 votes vote down vote up
/**
 * @param id 
 * 			component id of the editor
 * @param model
 * 			markdown model of the editor
 * @param compactMode
 * 			editor in compact mode occupies horizontal space and is suitable 
 * 			to be used in places such as comment aside the code
 */
public MarkdownEditor(String id, IModel<String> model, boolean compactMode, 
		@Nullable BlobRenderContext blobRenderContext) {
	super(id, model);
	this.compactMode = compactMode;
	
	String cookieKey;
	if (compactMode)
		cookieKey = "markdownEditor.compactMode.split";
	else
		cookieKey = "markdownEditor.normalMode.split";
	
	WebRequest request = (WebRequest) RequestCycle.get().getRequest();
	Cookie cookie = request.getCookie(cookieKey);
	initialSplit = cookie!=null && "true".equals(cookie.getValue());
	
	this.blobRenderContext = blobRenderContext;
}
 
Example #9
Source File: RedirectRequestHandler.java    From onedev with MIT License 6 votes vote down vote up
/** {@inheritDoc} */
public void respond(final IRequestCycle requestCycle)
{
	String location = requestCycle.getUrlRenderer().renderRelativeUrl(Url.parse(getRedirectUrl()));
	
	WebResponse response = (WebResponse)requestCycle.getResponse();

	if (status == HttpServletResponse.SC_MOVED_TEMPORARILY)
	{
		response.sendRedirect(location);
	}
	else
	{
		response.setStatus(status);

		if (((WebRequest)requestCycle.getRequest()).isAjax())
		{
			response.setHeader("Ajax-Location", location);
		}
		else
		{
			response.setHeader("Location", location);
		}
	}
}
 
Example #10
Source File: ConceptFeatureEditor.java    From inception with Apache License 2.0 6 votes vote down vote up
@Override
public String[] getInputAsArray()
{
    // If the web request includes the additional "identifier" parameter which is supposed
    // to contain the IRI of the selected item instead of its label, then we use that as the
    // value.
    WebRequest request = getWebRequest();
    IRequestParameters requestParameters = request.getRequestParameters();
    StringValue identifier = requestParameters
            .getParameterValue(getInputName() + ":identifier");
    
    if (!identifier.isEmpty()) {
        return new String[] { identifier.toString() };
    }
    
    return super.getInputAsArray();
}
 
Example #11
Source File: SourceFormatPanel.java    From onedev with MIT License 5 votes vote down vote up
public SourceFormatPanel(String id, 
		@Nullable OptionChangeCallback indentTypeChangeCallback, 
		@Nullable OptionChangeCallback tabSizeChangeCallback, 
		@Nullable OptionChangeCallback lineWrapModeChangeCallback) {
	super(id);

	this.indentTypeChangeCallback = indentTypeChangeCallback;
	this.tabSizeChangeCallback = tabSizeChangeCallback;
	this.lineWrapModeChangeCallback = lineWrapModeChangeCallback;
	
	WebRequest request = (WebRequest) RequestCycle.get().getRequest();
	Cookie cookie = request.getCookie(COOKIE_INDENT_TYPE);
	if (cookie != null)
		indentType = cookie.getValue();
	else
		indentType = "Tabs";
	
	cookie = request.getCookie(COOKIE_TAB_SIZE);
	if (cookie != null)
		tabSize = cookie.getValue();
	else
		tabSize = "4";
	
	cookie = request.getCookie(COOKIE_LINE_WRAP_MODE);
	if (cookie != null)
		lineWrapMode = cookie.getValue().replace('-', ' ');
	else
		lineWrapMode = "Soft wrap";
}
 
Example #12
Source File: AbstractSelect2Choice.java    From onedev with MIT License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();

	add(new DragAndDropBehavior());
	
	// configure the ajax callbacks

	AjaxSettings ajax = settings.getAjax(true);

	ajax.setData(String.format(
			"function(term, page) { return { select2_term: term, select2_page:page, '%s':true, '%s':[window.location.protocol, '//', window.location.host, window.location.pathname].join('')}; }",
			WebRequest.PARAM_AJAX, WebRequest.PARAM_AJAX_BASE_URL));

	ajax.setResults("function(data, page) { return data; }");

	// configure the localized strings/renderers
	getSettings().setFormatNoMatches("function() { return '" + getEscapedJsString("noMatches") + "';}");
	getSettings().setFormatInputTooShort("function(input, min) { return min - input.length == 1 ? '"
			+ getEscapedJsString("inputTooShortSingular") + "' : '" + getEscapedJsString("inputTooShortPlural")
			+ "'.replace('{number}', min - input.length); }");
	getSettings().setFormatSelectionTooBig(
			"function(limit) { return limit == 1 ? '" + getEscapedJsString("selectionTooBigSingular") + "' : '"
					+ getEscapedJsString("selectionTooBigPlural") + "'.replace('{limit}', limit); }");
	getSettings().setFormatLoadMore("function() { return '" + getEscapedJsString("loadMore") + "';}");
	getSettings().setFormatSearching("function() { return '" + getEscapedJsString("searching") + "';}");
}
 
Example #13
Source File: IssueActivitiesPanel.java    From onedev with MIT License 5 votes vote down vote up
public IssueActivitiesPanel(String panelId) {
	super(panelId);
	
	WebRequest request = (WebRequest) RequestCycle.get().getRequest();
	Cookie cookie = request.getCookie(COOKIE_SHOW_COMMENTS);
	if (cookie != null)
		showComments = Boolean.valueOf(cookie.getValue());
	
	cookie = request.getCookie(COOKIE_SHOW_CHANGE_HISTORY);
	if (cookie != null)
		showChangeHistory = Boolean.valueOf(cookie.getValue());
}
 
Example #14
Source File: SourceViewPanel.java    From onedev with MIT License 5 votes vote down vote up
private boolean isOutlineVisibleInitially() {
	if (hasOutline()) {
		WebRequest request = (WebRequest) RequestCycle.get().getRequest();
		Cookie cookie = request.getCookie(COOKIE_OUTLINE);
		if (cookie != null) {
			return cookie.getValue().equals("yes");
		} else {
			return !WicketUtils.isDevice();
		}
	} else {
		return false;
	}
}
 
Example #15
Source File: OneWebApplication.java    From onedev with MIT License 5 votes vote down vote up
@Override
public final IProvider<IExceptionMapper> getExceptionMapperProvider() {
	return new IProvider<IExceptionMapper>() {

		@Override
		public IExceptionMapper get() {
			return new DefaultExceptionMapper() {

				@Override
				protected IRequestHandler mapExpectedExceptions(Exception e, Application application) {
					RequestCycle requestCycle = RequestCycle.get();
					boolean isAjax = ((WebRequest)requestCycle.getRequest()).isAjax();
					if (isAjax && (e instanceof ListenerInvocationNotAllowedException || e instanceof ComponentNotFoundException))
						return EmptyAjaxRequestHandler.getInstance();
					
					IRequestMapper mapper = Application.get().getRootRequestMapper();
					if (mapper.mapRequest(requestCycle.getRequest()) instanceof ResourceReferenceRequestHandler)
						return new ResourceErrorRequestHandler(e);
					
					HttpServletResponse response = (HttpServletResponse) requestCycle.getResponse().getContainerResponse();
					if (!response.isCommitted()) {
						InUseException inUseException = ExceptionUtils.find(e, InUseException.class);
						if (inUseException != null)
							return createPageRequestHandler(new PageProvider(new InUseErrorPage(inUseException)));
						else
							return createPageRequestHandler(new PageProvider(new GeneralErrorPage(e)));
					} else {
						return super.mapExpectedExceptions(e, application);
					}
				}
				
			};
		}
		
	};
}
 
Example #16
Source File: AddAnyButton.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
@Override
protected void onBeforeRender() {

    final BookmarkablePageLink link = (BookmarkablePageLink) getWicketSupportFacade().links().newProductLink("link", supplier, product.getProductId());

    final String lang = getLocale().getLanguage();

    final CharSequence uri = link.urlFor(link.getPageClass(), link.getPageParameters());
    final HttpServletRequest req = (HttpServletRequest)((WebRequest) RequestCycle.get().getRequest()).getContainerRequest();
    final String absUri = RequestUtils.toAbsolutePath(req.getRequestURL().toString(), uri.toString());

    final String name = getI18NSupport().getFailoverModel(product.getDisplayName(), product.getName()).getValue(lang);

    final StringBuilder anchor = new StringBuilder()
            .append("<a class=\"a2a_dd\" href=\"http://www.addtoany.com/share_save?linkurl=")
            .append(absUri)
            .append("&amp;linkname=")
            .append(name)
            .append("\">Share</a>");

    final StringBuilder js = new StringBuilder()
            .append("<script type=\"text/javascript\">\n")
            .append("            var a2a_config = a2a_config || {};\n")
            .append("            a2a_config.linkname = \"").append(name).append("\";\n")
            .append("            a2a_config.linkurl = \"").append(absUri).append("\";\n")
            .append("            a2a_config.locale = \"").append(lang).append("\";")
            .append("            a2a_config.color_main = \"D7E5ED\";")
            .append("            a2a_config.color_border = \"AECADB\";")
            .append("            a2a_config.color_link_text = \"333333\";")
            .append("            a2a_config.color_link_text_hover = \"333333\";")
            .append("</script>");

    addOrReplace(new Label("anchor", anchor.toString()).setEscapeModelStrings(false));
    addOrReplace(new Label("js", js.toString()).setEscapeModelStrings(false));

    super.onBeforeRender();
}
 
Example #17
Source File: GitProtocolPanel.java    From onedev with MIT License 5 votes vote down vote up
public GitProtocolPanel(String id) {
	super(id);

	if (SecurityUtils.getUser() != null) {
		WebRequest request = (WebRequest) RequestCycle.get().getRequest();
		Cookie cookie = request.getCookie(COOKIE_USE_SSH);
		useSsh = cookie!=null && String.valueOf(true).equals(cookie.getValue());
	} else {
		useSsh = false;
	}
}
 
Example #18
Source File: RestartResponseAtInterceptPageException.java    From onedev with MIT License 5 votes vote down vote up
public static void set()
{
	Session session = Session.get();
	session.bind();
	InterceptData data = new InterceptData();
	Request request = RequestCycle.get().getRequest();
	data.originalUrl = request.getOriginalUrl();
	data.originalUrl.setHost(null);
	data.originalUrl.setPort(null);
	data.originalUrl.setProtocol(null);
	
	Iterator<QueryParameter> itor = data.originalUrl.getQueryParameters().iterator();
	while (itor.hasNext())
	{
		QueryParameter parameter = itor.next();
		String parameterName = parameter.getName();
		if (WebRequest.PARAM_AJAX.equals(parameterName) ||
			WebRequest.PARAM_AJAX_BASE_URL.equals(parameterName) ||
			WebRequest.PARAM_AJAX_REQUEST_ANTI_CACHE.equals(parameterName))
		{
			itor.remove();
		}
	}

	data.postParameters = new HashMap<String, List<StringValue>>();
	for (String s : request.getPostParameters().getParameterNames())
	{
		if (WebRequest.PARAM_AJAX.equals(s) || WebRequest.PARAM_AJAX_BASE_URL.equals(s) ||
			WebRequest.PARAM_AJAX_REQUEST_ANTI_CACHE.equals(s))
		{
			continue;
		}
		data.postParameters.put(s, new ArrayList<StringValue>(request.getPostParameters()
			.getParameterValues(s)));
	}
	session.setMetaData(key, data);
}
 
Example #19
Source File: OMetricsRequestCycleListener.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void onBeginRequest(RequestCycle cycle) {
	Histogram.Timer requestTimer = HISTOGRAM_REQUESTS
									.labels(Boolean.toString(((WebRequest)cycle.getRequest()).isAjax()))
									.startTimer();
	cycle.setMetaData(REQUESTS_HISTOGRAM_KEY, requestTimer);
}
 
Example #20
Source File: OMetricsRequestCycleListener.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void onRequestHandlerExecuted(RequestCycle cycle, IRequestHandler handler) {
	String ajaxLabel = Boolean.toString(((WebRequest)cycle.getRequest()).isAjax());
	COUNTER_EXECUTIONS.labels(ajaxLabel,
								handler.getClass().getSimpleName()).inc();
	if(handler instanceof IPageClassRequestHandler) {
		COUNTER_PAGES.labels(ajaxLabel,
				((IPageClassRequestHandler)handler).getPageClass().getSimpleName()).inc();
	}
}
 
Example #21
Source File: MenuMobilePage.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("serial")
public MenuMobilePage(final PageParameters parameters)
{
  super(parameters);
  if (getUser().getAttribute(UserFilter.USER_ATTR_STAY_LOGGED_IN) != null) {
    getUser().removeAttribute(UserFilter.USER_ATTR_STAY_LOGGED_IN);
    if (WicketUtils.contains(parameters, PARAM_HOME_KEY) == false) {
      final RecentMobilePageInfo pageInfo = (RecentMobilePageInfo) UserPreferencesHelper
          .getEntry(AbstractSecuredMobilePage.USER_PREF_RECENT_PAGE);
      if (pageInfo != null && pageInfo.getPageClass() != null) {
        throw new RestartResponseException((Class< ? extends Page>) pageInfo.getPageClass(), pageInfo.restorePageParameters());
      }
    }
  }
  setNoBackButton();
  final ListViewPanel listViewPanel = new ListViewPanel("menu");
  pageContainer.add(listViewPanel);
  listViewPanel.add(new ListViewItemPanel(listViewPanel.newChildId(), getString("menu.main.title")).setListDivider());
  final Menu menu = menuBuilder.getMobileMenu(PFUserContext.getUser());
  if (menu.getMenuEntries() != null) {
    for (final MenuEntry menuEntry : menu.getMenuEntries()) {
      if (menuEntry.isVisible() == true) {
        listViewPanel.add(new ListViewItemPanel(listViewPanel.newChildId(), menuEntry.getMobilePageClass(), getString(menuEntry
            .getI18nKey())));
      }
    }
  }
  listViewPanel.add(new ListViewItemPanel(listViewPanel.newChildId(), new BookmarkablePageLink<String>(ListViewItemPanel.LINK_ID,
      WicketUtils.getDefaultPage()), getString("menu.mobile.fullWebVersion")).setAsExternalLink());

  listViewPanel.add(new ListViewItemPanel(listViewPanel.newChildId(), new Link<String>(ListViewItemPanel.LINK_ID) {
    @Override
    public void onClick()
    {
      LoginPage.logout((MySession) getSession(), (WebRequest) getRequest(), (WebResponse) getResponse(), userXmlPreferencesCache,
          menuBuilder);
      setResponsePage(LoginMobilePage.class);
    }

  }, getString("menu.logout")) {
  });
  if (getMySession().isIOSDevice() == true) {
    pageContainer.add(new Label("iOSHint", getString("mobile.iOS.startScreenInfo")));
  } else {
    pageContainer.add(new Label("iOSHint", getString("mobile.others.startScreenInfo")));
  }
}
 
Example #22
Source File: NavTopPanel.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public void init(final AbstractSecuredPage page)
{
  getMenu();
  this.favoritesMenu = FavoritesMenu.get();
  final WebMarkupContainer goMobile = new WebMarkupContainer("goMobile");
  add(goMobile);
  if (page.getMySession().isMobileUserAgent() == true) {
    goMobile.add(new BookmarkablePageLink<Void>("link", MenuMobilePage.class));
  } else {
    goMobile.setVisible(false);
  }
  add(new MenuConfig("menuconfig", getMenu(), favoritesMenu));
  @SuppressWarnings("serial")
  final Form<String> searchForm = new Form<String>("searchForm") {
    private String searchString;

    /**
     * @see org.apache.wicket.markup.html.form.Form#onSubmit()
     */
    @Override
    protected void onSubmit()
    {
      csrfTokenHandler.onSubmit();
      if (StringUtils.isNotBlank(searchString) == true) {
        final SearchPage searchPage = new SearchPage(new PageParameters(), searchString);
        setResponsePage(searchPage);
      }
      super.onSubmit();
    }
  };
  csrfTokenHandler = new CsrfTokenHandler(searchForm);
  add(searchForm);
  final TextField<String> searchField = new TextField<String>("searchField", new PropertyModel<String>(searchForm, "searchString"));
  WicketUtils.setPlaceHolderAttribute(searchField, getString("search.search"));
  searchForm.add(searchField);
  add(new BookmarkablePageLink<Void>("feedbackLink", FeedbackPage.class));
  {
    @SuppressWarnings("serial")
    final AjaxLink<Void> showBookmarkLink = new AjaxLink<Void>("showBookmarkLink") {
      /**
       * @see org.apache.wicket.ajax.markup.html.AjaxLink#onClick(org.apache.wicket.ajax.AjaxRequestTarget)
       */
      @Override
      public void onClick(final AjaxRequestTarget target)
      {
        bookmarkDialog.open(target);
        // Redraw the content:
        bookmarkDialog.redraw().addContent(target);
      }
    };
    add(showBookmarkLink);
    addBookmarkDialog();
  }
  {
    add(new Label("user", PFUserContext.getUser().getFullname()));
    if (accessChecker.isRestrictedUser() == true) {
      // Show ChangePaswordPage as my account for restricted users.
      final BookmarkablePageLink<Void> changePasswordLink = new BookmarkablePageLink<Void>("myAccountLink", ChangePasswordPage.class);
      add(changePasswordLink);
    } else {
      final BookmarkablePageLink<Void> myAccountLink = new BookmarkablePageLink<Void>("myAccountLink", MyAccountEditPage.class);
      add(myAccountLink);
    }
    final BookmarkablePageLink<Void> documentationLink = new BookmarkablePageLink<Void>("documentationLink", DocumentationPage.class);
    add(documentationLink);

    @SuppressWarnings("serial")
    final Link<String> logoutLink = new Link<String>("logoutLink") {
      @Override
      public void onClick()
      {
        LoginPage.logout((MySession) getSession(), (WebRequest) getRequest(), (WebResponse) getResponse(), userXmlPreferencesCache);
        setResponsePage(LoginPage.class);
      };
    };
    add(logoutLink);
  }
  addCompleteMenu();
  addFavoriteMenu();
}
 
Example #23
Source File: LoginPage.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
public static void logout(final MySession mySession, final WebRequest request, final WebResponse response,
    final UserXmlPreferencesCache userXmlPreferencesCache)
{
  logout(mySession, request, response, userXmlPreferencesCache, null);
}
 
Example #24
Source File: OMetricsRequestCycleListener.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
@Override
public IRequestHandler onException(RequestCycle cycle, Exception ex) {
	COUNTER_EXCEPTIONS.labels(Boolean.toString(((WebRequest)cycle.getRequest()).isAjax())).inc();
	return null;
}
 
Example #25
Source File: RevisionDiffPanel.java    From onedev with MIT License 4 votes vote down vote up
public RevisionDiffPanel(String id, IModel<Project> projectModel, IModel<PullRequest> requestModel, 
		String oldRev, String newRev, IModel<String> pathFilterModel, IModel<WhitespaceOption> whitespaceOptionModel, 
		@Nullable IModel<String> blameModel, @Nullable CommentSupport commentSupport) {
	super(id);
	
	this.projectModel = projectModel;
	this.requestModel = requestModel;
	this.oldRev = oldRev;
	this.newRev = newRev;
	this.pathFilterModel = pathFilterModel;
	this.blameModel = new IModel<String>() {

		@Override
		public void detach() {
			blameModel.detach();
		}

		@Override
		public String getObject() {
			return blameModel.getObject();
		}

		@Override
		public void setObject(String object) {
			AjaxRequestTarget target = RequestCycle.get().find(AjaxRequestTarget.class);
			String prevBlameFile = blameModel.getObject();
			blameModel.setObject(object);
			if (prevBlameFile != null && object != null && !prevBlameFile.equals(object)) {
				SourceAware sourceAware = getSourceAware(prevBlameFile);
				sourceAware.onUnblame(target);
			}
			target.appendJavaScript("onedev.server.revisionDiff.reposition();");
		}
		
	};
	this.whitespaceOptionModel = whitespaceOptionModel;
	this.commentSupport = commentSupport;
	
	WebRequest request = (WebRequest) RequestCycle.get().getRequest();
	Cookie cookie = request.getCookie(COOKIE_VIEW_MODE);
	if (cookie == null)
		diffMode = DiffViewMode.UNIFIED;
	else
		diffMode = DiffViewMode.valueOf(cookie.getValue());
}
 
Example #26
Source File: AbstractWebSocketProcessor.java    From onedev with MIT License 4 votes vote down vote up
/**
 * Constructor.
 *
 * @param request
 *      the http request that was used to create the TomcatWebSocketProcessor
 * @param application
 *      the current Wicket Application
 */
public AbstractWebSocketProcessor(final HttpServletRequest request, final WebApplication application)
{
	final HttpSession httpSession = request.getSession(true);
	if (httpSession == null)
	{
		throw new IllegalStateException("There is no HTTP Session bound. Without a session Wicket won't be " +
				"able to find the stored page to update its components");
	}
	this.sessionId = httpSession.getId();

	String pageId = request.getParameter("pageId");
	resourceName = request.getParameter("resourceName");
	if (Strings.isEmpty(pageId) && Strings.isEmpty(resourceName))
	{
		throw new IllegalArgumentException("The request should have either 'pageId' or 'resourceName' parameter!");
	}
	if (Strings.isEmpty(pageId) == false)
	{
		this.pageId = Integer.parseInt(pageId, 10);
	}
	else
	{
		this.pageId = NO_PAGE_ID;
	}

	String baseUrl = request.getParameter(WebRequest.PARAM_AJAX_BASE_URL);
	Checks.notNull(baseUrl, String.format("Request parameter '%s' is required!", WebRequest.PARAM_AJAX_BASE_URL));
	this.baseUrl = Url.parse(baseUrl);

	WicketFilter wicketFilter = application.getWicketFilter();
	this.servletRequest = new ServletRequestCopy(request);

	this.application = Args.notNull(application, "application");

	this.webSocketSettings = WebSocketSettings.Holder.get(application);

	this.webRequest = webSocketSettings.newWebSocketRequest(request, wicketFilter.getFilterPath());

	this.connectionRegistry = webSocketSettings.getConnectionRegistry();

	this.connectionFilter = webSocketSettings.getConnectionFilter();
}