org.apache.wicket.request.Request Java Examples

The following examples show how to use org.apache.wicket.request.Request. 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: NextServerSession.java    From nextreports-server with Apache License 2.0 6 votes vote down vote up
public NextServerSession(Request request) {
		super(request);
		Injector.get().inject(this);
		
		sectionContexts = new HashMap<String, SectionContext>();
		List<Section> sections = sectionManager.getSections();		
		for (Section section : sections) {			
			sectionContexts.put(section.getId(), SectionContextFactory.createSectionContext(section));
		}
//		if (!sections.isEmpty()) {
//			selectedSectionId = sections.get(0).getId();
//		}
		String language = storageService.getSettings().getLanguage();
		Locale locale = LanguageManager.getInstance().getLocale(language);
		setLocale(locale);
		LOG.info("--------------------> Set locale to: " + language);		
	}
 
Example #2
Source File: SyncopeConsoleSession.java    From syncope with Apache License 2.0 6 votes vote down vote up
public SyncopeConsoleSession(final Request request) {
    super(request);

    clientFactory = SyncopeWebApplication.get().newClientFactory();
    anonymousClient = clientFactory.create(new AnonymousAuthenticationHandler(
            SyncopeWebApplication.get().getAnonymousUser(),
            SyncopeWebApplication.get().getAnonymousKey()));

    platformInfo = anonymousClient.getService(SyncopeService.class).platform();
    systemInfo = anonymousClient.getService(SyncopeService.class).system();

    executor = new ThreadPoolTaskExecutor();
    executor.setWaitForTasksToCompleteOnShutdown(false);
    executor.setCorePoolSize(SyncopeWebApplication.get().getCorePoolSize());
    executor.setMaxPoolSize(SyncopeWebApplication.get().getMaxPoolSize());
    executor.setQueueCapacity(SyncopeWebApplication.get().getQueueCapacity());
    executor.initialize();
}
 
Example #3
Source File: SpringAuthenticatedWebSession.java    From webanno with Apache License 2.0 6 votes vote down vote up
public SpringAuthenticatedWebSession(Request request)
{
    super(request);
    injectDependencies();
    ensureDependenciesNotNull();
    
    // If the a proper (non-anonymous) authentication has already been performed (e.g. via
    // external pre-authentication) then also mark the Wicket session as signed-in.
    Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
    if (
            authentication != null && 
            authentication.isAuthenticated() && 
            authentication instanceof PreAuthenticatedAuthenticationToken
            //!(authentication instanceof AnonymousAuthenticationToken && !isSignedIn())
    ) {
        signIn(true);
    }
}
 
Example #4
Source File: PreferenceManager.java    From syncope with Apache License 2.0 6 votes vote down vote up
public static void set(final Request request, final Response response, final Map<String, List<String>> prefs) {
    Map<String, String> current = new HashMap<>();

    String prefString = COOKIE_UTILS.load(COOKIE_NAME);
    if (prefString != null) {
        current.putAll(getPrefs(new String(Base64.getDecoder().decode(prefString.getBytes()))));
    }

    // after retrieved previous setting in order to overwrite the key ...
    prefs.forEach((key, values) -> current.put(key, StringUtils.join(values, ";")));

    try {
        COOKIE_UTILS.save(COOKIE_NAME, Base64.getEncoder().encodeToString(setPrefs(current).getBytes()));
    } catch (IOException e) {
        LOG.error("Could not save {} info: {}", PreferenceManager.class.getSimpleName(), current, e);
    }
}
 
Example #5
Source File: PreferenceManager.java    From syncope with Apache License 2.0 6 votes vote down vote up
public static void set(final Request request, final Response response, final String key, final String value) {
    String prefString = COOKIE_UTILS.load(COOKIE_NAME);

    final Map<String, String> current = new HashMap<>();
    if (prefString != null) {
        current.putAll(getPrefs(new String(Base64.getDecoder().decode(prefString.getBytes()))));
    }

    // after retrieved previous setting in order to overwrite the key ...
    current.put(key, value);

    try {
        COOKIE_UTILS.save(COOKIE_NAME, Base64.getEncoder().encodeToString(setPrefs(current).getBytes()));
    } catch (IOException e) {
        LOG.error("Could not save {} info: {}", PreferenceManager.class.getSimpleName(), current, e);
    }
}
 
Example #6
Source File: MySession.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
public MySession(final Request request)
{
  super(request);
  setLocale(request);
  final ClientInfo info = getClientInfo();
  if (info instanceof WebClientInfo) {
    clientProperties = ((WebClientInfo) clientInfo).getProperties();
    clientProperties.setTimeZone(PFUserContext.getTimeZone());
    userAgent = ((WebClientInfo) info).getUserAgent();
    userAgentDevice = UserAgentDevice.getUserAgentDevice(userAgent);
    userAgentOS = UserAgentOS.getUserAgentOS(userAgent);
    mobileUserAgent = userAgentDevice.isMobile();
    final UserAgentDetection userAgentDetection = UserAgentDetection.browserDetect(userAgent);
    userAgentBrowser = userAgentDetection.getUserAgentBrowser();
    userAgentBrowserVersionString = userAgentDetection.getUserAgentBrowserVersion();
  } else {
    log.error("Oups, ClientInfo is not from type WebClientInfo: " + info);
  }
  setUser(PFUserContext.getUser());
  this.csrfToken = NumberHelper.getSecureRandomUrlSaveString(20);
}
 
Example #7
Source File: MenuConfig.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param id
 */
@SuppressWarnings("serial")
public MenuConfig(final String id, final Menu menu, final FavoritesMenu favoritesMenu)
{
  super(id);
  configureLink = new WebMarkupContainer("configureLink");
  add(configureLink);
  configureBehavior = new AbstractDefaultAjaxBehavior() {
    @Override
    protected void respond(final AjaxRequestTarget target)
    {
      final Request request = RequestCycle.get().getRequest();
      final StringValue configuration = request.getPostParameters().getParameterValue("configuration");
      final String xml = configuration.toString("");
      if (log.isDebugEnabled() == true) {
        log.debug(xml);
      }
      favoritesMenu.readFromXml(xml);
      favoritesMenu.storeAsUserPref();
    }
  };
  add(configureBehavior);
  add(new MenuConfigContent("content", menu));
}
 
Example #8
Source File: GetEventsCallback.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void respond() {
	Request r = getCalendar().getRequest();

	String sid = r.getRequestParameters().getParameterValue(SOURCE_ID).toString();
	DateTime start = new DateTime(r.getRequestParameters().getParameterValue("start").toLong());
	DateTime end = new DateTime(r.getRequestParameters().getParameterValue("end").toLong());

	if (getCalendar().getConfig().isIgnoreTimezone()) {
		// Convert to same DateTime in local time zone.
		int remoteOffset = -r.getRequestParameters().getParameterValue("timezoneOffset").toInt();
		int localOffset = DateTimeZone.getDefault().getOffset(null) / 60000;
		int minutesAdjustment = remoteOffset - localOffset;
		start = start.plusMinutes(minutesAdjustment);
		end = end.plusMinutes(minutesAdjustment);
	}
	EventSource source = getCalendar().getEventManager().getEventSource(sid);
	EventProvider provider = source.getEventProvider();
	String response = getCalendar().toJson(provider.getEvents(start, end));

	getCalendar().getRequestCycle().scheduleRequestHandlerAfterCurrent(
		new TextRequestHandler("application/json", "UTF-8", response));

}
 
Example #9
Source File: EventDroppedCallback.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected boolean onEvent(final AjaxRequestTarget target)
{
  final Request r = getCalendar().getRequest();
  final String eventId = r.getRequestParameters().getParameterValue("eventId").toString();
  final String sourceId = r.getRequestParameters().getParameterValue("sourceId").toString();

  final EventSource source = getCalendar().getEventManager().getEventSource(sourceId);
  final Event event = source.getEventProvider().getEventForId(eventId);

  final int dayDelta = r.getRequestParameters().getParameterValue("dayDelta").toInt();
  final int minuteDelta = r.getRequestParameters().getParameterValue("minuteDelta").toInt();
  final boolean allDay = r.getRequestParameters().getParameterValue("allDay").toBoolean();

  return onEventDropped(new DroppedEvent(source, event, dayDelta, minuteDelta, allDay), new CalendarResponse(getCalendar(), target));
}
 
Example #10
Source File: EventResizedCallback.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected boolean onEvent(final AjaxRequestTarget target) {
  final Request r = getCalendar().getRequest();
  final String eventId = r.getRequestParameters().getParameterValue("eventId").toString();
  final String sourceId = r.getRequestParameters().getParameterValue("sourceId").toString();

  final EventSource source = getCalendar().getEventManager().getEventSource(sourceId);
  final Event event = source.getEventProvider().getEventForId(eventId);

  final int dayDelta = r.getRequestParameters().getParameterValue("dayDelta").toInt();
  final int minuteDelta = r.getRequestParameters().getParameterValue("minuteDelta").toInt();

  return onEventResized(new ResizedEvent(source, event, dayDelta, minuteDelta), new CalendarResponse(
      getCalendar(), target));

}
 
Example #11
Source File: ViewDisplayCallback.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void respond(final AjaxRequestTarget target) {
  final Request r = target.getPage().getRequest();
  final ViewType type = ViewType.forCode(r.getRequestParameters().getParameterValue("view").toString());
  final DateTimeFormatter fmt = ISODateTimeFormat.dateTimeParser().withZone(PFUserContext.getDateTimeZone());
  final DateMidnight start = fmt.parseDateTime(r.getRequestParameters().getParameterValue("start").toString())
      .toDateMidnight();
  final DateMidnight end = fmt.parseDateTime(r.getRequestParameters().getParameterValue("end").toString())
      .toDateMidnight();
  final DateMidnight visibleStart = fmt.parseDateTime(
      r.getRequestParameters().getParameterValue("visibleStart").toString()).toDateMidnight();
  final DateMidnight visibleEnd = fmt
      .parseDateTime(r.getRequestParameters().getParameterValue("visibleEnd").toString()).toDateMidnight();
  final View view = new View(type, start, end, visibleStart, visibleEnd);
  final CalendarResponse response = new CalendarResponse(getCalendar(), target);
  onViewDisplayed(view, response);
}
 
Example #12
Source File: DateRangeSelectedCallback.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void respond(final AjaxRequestTarget target) {
  final Request r = getCalendar().getRequest();

  DateTime start = new DateTime(r.getRequestParameters().getParameterValue("startDate").toLong());
  DateTime end = new DateTime(r.getRequestParameters().getParameterValue("endDate").toLong());

  if (ignoreTimezone) {
    // Convert to same DateTime in local time zone.
    final int remoteOffset = -r.getRequestParameters().getParameterValue("timezoneOffset").toInt();
    final int localOffset = DateTimeZone.getDefault().getOffset(null) / 60000;
    final int minutesAdjustment = remoteOffset - localOffset;
    start = start.plusMinutes(minutesAdjustment);
    end = end.plusMinutes(minutesAdjustment);
  }
  final boolean allDay = r.getRequestParameters().getParameterValue("allDay").toBoolean();
  onSelect(new SelectedRange(start, end, allDay), new CalendarResponse(getCalendar(), target));

}
 
Example #13
Source File: RestartResponseAtInterceptPageException.java    From onedev with MIT License 6 votes vote down vote up
@Override
public IRequestHandler mapRequest(Request request)
{
	InterceptData data = matchedData(request);
	if (data != null)
	{
		if (data.postParameters.isEmpty() == false &&
			request.getPostParameters() instanceof IWritableRequestParameters)
		{
			IWritableRequestParameters parameters = (IWritableRequestParameters)request.getPostParameters();
			parameters.reset();
			for (String s : data.postParameters.keySet())
			{
				parameters.setParameterValues(s, data.postParameters.get(s));
			}
		}
		InterceptData.clear();
	}
	return null;
}
 
Example #14
Source File: MySession.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public void login(final PFUserDO user, final Request request)
{
  if (user == null) {
    log.warn("Oups, no user given to log in.");
    return;
  }
  this.user = user;
  log.debug("User logged in: " + user.getShortDisplayName());
  PFUserContext.setUser(user);
  setLocale(request);
}
 
Example #15
Source File: AbstractODocumentAliasMapper.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected PageParameters extractPageParameters(Request request, Url url) {
    PageParameters parameters = super.extractPageParameters(request, url);
    String value = getValueAsString(parameters);

    if (value != null) {
        parameters.set(parameter, value);
    }

    return parameters;
}
 
Example #16
Source File: AbstractODocumentAliasMapper.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected UrlInfo parseRequest(Request request) {
    UrlInfo urlInfo = super.parseRequest(request);
    String param = urlInfo != null ? urlInfo.getPageParameters().get(parameter).toOptionalString() : null;
    if (!Strings.isNullOrEmpty(param)) {
        return urlInfo;
    }
    return null;
}
 
Example #17
Source File: PreferenceManager.java    From syncope with Apache License 2.0 5 votes vote down vote up
public static List<String> getList(final Request request, final String key) {
    final List<String> result = new ArrayList<>();

    final String compound = get(request, key);

    if (StringUtils.isNotBlank(compound)) {
        String[] items = compound.split(";");
        result.addAll(List.of(items));
    }

    return result;
}
 
Example #18
Source File: EventClickedCallback.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void respond(final AjaxRequestTarget target) {
  final Request r = getCalendar().getRequest();
  final String eventId = r.getRequestParameters().getParameterValue("eventId").toString();
  final String sourceId = r.getRequestParameters().getParameterValue("sourceId").toString();

  final EventSource source = getCalendar().getEventManager().getEventSource(sourceId);
  final Event event = source.getEventProvider().getEventForId(eventId);

  onClicked(new ClickedEvent(source, event), new CalendarResponse(getCalendar(), target));
}
 
Example #19
Source File: PreferenceManager.java    From syncope with Apache License 2.0 5 votes vote down vote up
public static Integer getPaginatorRows(final Request request, final String key) {
    Integer result = getPaginatorChoices().get(0);

    String value = get(request, key);
    if (value != null) {
        result = NumberUtils.toInt(value, 10);
    }

    return result;
}
 
Example #20
Source File: PreferenceManager.java    From syncope with Apache License 2.0 5 votes vote down vote up
public static String get(final Request request, final String key) {
    String result = null;

    String prefString = COOKIE_UTILS.load(COOKIE_NAME);
    if (prefString != null) {
        Map<String, String> prefs = getPrefs(new String(Base64.getDecoder().decode(prefString.getBytes())));
        result = prefs.get(key);
    }

    return result;
}
 
Example #21
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 #22
Source File: SyncopeEnduserSession.java    From syncope with Apache License 2.0 5 votes vote down vote up
public SyncopeEnduserSession(final Request request) {
    super(request);

    clientFactory = SyncopeWebApplication.get().newClientFactory();
    anonymousClient = clientFactory.create(new AnonymousAuthenticationHandler(
            SyncopeWebApplication.get().getAnonymousUser(),
            SyncopeWebApplication.get().getAnonymousKey()));

    executor = new ThreadPoolTaskExecutor();
    executor.setWaitForTasksToCompleteOnShutdown(false);
    executor.setCorePoolSize(SyncopeWebApplication.get().getCorePoolSize());
    executor.setMaxPoolSize(SyncopeWebApplication.get().getMaxPoolSize());
    executor.setQueueCapacity(SyncopeWebApplication.get().getQueueCapacity());
    executor.initialize();
}
 
Example #23
Source File: KeyPressBehavior.java    From AppStash with Apache License 2.0 5 votes vote down vote up
@Override
protected void onEvent(AjaxRequestTarget target) {
    //Extract the keycode parameter from RequestCycle
    final Request request = RequestCycle.get().getRequest();
    final String jsKeycode = request.getRequestParameters()
            .getParameterValue("keycode").toString("");

    switch (jsKeycode) {
        case "112":
            selectorBean.standard();
            target.getPage().setResponsePage(currentPage);
            break;
        case "113":
            selectorBean.next();
            target.getPage().setResponsePage(currentPage);
            break;
        case "114":
            tooglesBean.toogleHighlightingFeature();
            target.getPage().setResponsePage(currentPage);
            break;
        case "115":
            tooglesBean.toogleTopSellerFeature();
            target.getPage().setResponsePage(currentPage);
            break;
        default:
    }
}
 
Example #24
Source File: KeyPressBehavior.java    From the-app with Apache License 2.0 5 votes vote down vote up
@Override
protected void onEvent(AjaxRequestTarget target) {
    //Extract the keycode parameter from RequestCycle
    final Request request = RequestCycle.get().getRequest();
    final String jsKeycode = request.getRequestParameters()
            .getParameterValue("keycode").toString("");

    switch (jsKeycode) {
        case "112":
            selectorBean.standard();
            target.getPage().setResponsePage(currentPage);
            break;
        case "113":
            selectorBean.next();
            target.getPage().setResponsePage(currentPage);
            break;
        case "114":
            tooglesBean.toogleHighlightingFeature();
            target.getPage().setResponsePage(currentPage);
            break;
        case "115":
            tooglesBean.toogleTopSellerFeature();
            target.getPage().setResponsePage(currentPage);
            break;
        default:
    }
}
 
Example #25
Source File: ToDoApplication.java    From isis-app-todoapp with Apache License 2.0 5 votes vote down vote up
@Override
public Session newSession(final Request request, final Response response) {
    if(!DEMO_MODE_USING_CREDENTIALS_AS_QUERYARGS) {
        return super.newSession(request, response);
    } 
    
    // else demo mode
    final AuthenticatedWebSessionForIsis s = (AuthenticatedWebSessionForIsis) super.newSession(request, response);
    final org.apache.wicket.util.string.StringValue user = request.getRequestParameters().getParameterValue("user");
    final org.apache.wicket.util.string.StringValue password = request.getRequestParameters().getParameterValue("pass");
    s.signIn(user.toString(), password.toString());
    return s;
}
 
Example #26
Source File: RestartResponseAtInterceptPageException.java    From onedev with MIT License 5 votes vote down vote up
private InterceptData matchedData(Request request)
{
	InterceptData data = InterceptData.get();
	if (data != null && data.originalUrl.equals(request.getOriginalUrl()))
	{
		return data;
	}
	return null;
}
 
Example #27
Source File: LogoutPanel.java    From webanno with Apache License 2.0 5 votes vote down vote up
/**
 * Checks if auto-logout is enabled. For Winstone, we get a max session length of 0, so here it
 * is disabled.
 */
private int getAutoLogoutTime()
{
    int duration = 0;
    Request request = RequestCycle.get().getRequest();
    if (request instanceof ServletWebRequest) {
        HttpSession session = ((ServletWebRequest) request).getContainerRequest().getSession();
        if (session != null) {
            duration = session.getMaxInactiveInterval();
        }
    }        
    return duration;
}
 
Example #28
Source File: BasicResourceReferenceMapper.java    From onedev with MIT License 5 votes vote down vote up
@Override
public int getCompatibilityScore(Request request)
{
	Url url = request.getUrl();

	int score = -1;
	if (canBeHandled(url))
	{
		score = 1;
	}

	return score;
}
 
Example #29
Source File: StorefrontApplication.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public Session newSession(Request request, Response response) {

    final ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    final LanguageService languageService = ctx.getBean(
            "languageService",
            LanguageService.class);

    return super.newSession(
            new StorefrontRequestDecorator(request, languageService.getSupportedLanguages(ShopCodeContext.getShopCode())),
            response);

}
 
Example #30
Source File: ShopSession.java    From the-app with Apache License 2.0 4 votes vote down vote up
public ShopSession(Request request) {
    super(request);
}