Java Code Examples for org.apache.wicket.request.cycle.RequestCycle#getMetaData()
The following examples show how to use
org.apache.wicket.request.cycle.RequestCycle#getMetaData() .
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: RecommendationServiceImpl.java From inception with Apache License 2.0 | 6 votes |
@EventListener public void onAnnotation(AnnotationEvent aEvent) { RequestCycle requestCycle = RequestCycle.get(); if (requestCycle == null) { return; } Set<RecommendationStateKey> dirties = requestCycle.getMetaData(DIRTIES); if (dirties == null) { dirties = new HashSet<>(); requestCycle.setMetaData(DIRTIES, dirties); } dirties.add(new RecommendationStateKey(aEvent.getUser(), aEvent.getProject())); }
Example 2
Source File: RecommendationServiceImpl.java From inception with Apache License 2.0 | 6 votes |
@Override public void onEndRequest(RequestCycle cycle) { Set<RecommendationStateKey> dirties = cycle.getMetaData(DIRTIES); Set<RecommendationStateKey> committed = cycle.getMetaData(COMMITTED); if (dirties == null || committed == null) { return; } for (RecommendationStateKey committedKey : committed) { if (!dirties.contains(committedKey)) { // Committed but not dirty, so nothing to do. continue; } Project project = projectService.getProject(committedKey.getProjectId()); if (project == null) { // Concurrent action has deleted project, so we can ignore this continue; } triggerTrainingAndClassification(committedKey.getUser(), project, "Committed dirty CAS at end of request", currentDocument); } }
Example 3
Source File: AbstractAuthorizingRealm.java From onedev with MIT License | 6 votes |
@Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { Long userId = (Long) principals.getPrimaryPrincipal(); RequestCycle requestCycle = RequestCycle.get(); if (requestCycle != null) { Map<Long, AuthorizationInfo> authorizationInfos = requestCycle.getMetaData(AUTHORIZATION_INFOS); if (authorizationInfos == null) { authorizationInfos = new HashMap<>(); requestCycle.setMetaData(AUTHORIZATION_INFOS, authorizationInfos); } AuthorizationInfo authorizationInfo = authorizationInfos.get(userId); if (authorizationInfo == null) { authorizationInfo = newAuthorizationInfo(userId); authorizationInfos.put(userId, authorizationInfo); } return authorizationInfo; } else { return newAuthorizationInfo(userId); } }
Example 4
Source File: LazyAuthorizationRequestCycleListener.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Override public void onRequestHandlerResolved(RequestCycle cycle, IRequestHandler handler) { Boolean lazyAuthorized = cycle.getMetaData(LAZY_AUTHORIZED); if(lazyAuthorized!=null && !lazyAuthorized) { cycle.setMetaData(LAZY_AUTHORIZED, null); throw new LazyAuthorizationException(); } }
Example 5
Source File: RecommendationServiceImpl.java From inception with Apache License 2.0 | 4 votes |
@EventListener public void onAfterCasWritten(AfterCasWrittenEvent aEvent) { RequestCycle requestCycle = RequestCycle.get(); if (requestCycle == null) { return; } Set<RecommendationStateKey> committed = requestCycle.getMetaData(COMMITTED); if (committed == null) { committed = new HashSet<>(); requestCycle.setMetaData(COMMITTED, committed); } committed.add(new RecommendationStateKey(aEvent.getDocument().getUser(), aEvent.getDocument().getProject())); boolean containsTrainingTrigger = false; for (IRequestCycleListener listener : requestCycle.getListeners()) { if (listener instanceof TriggerTrainingTaskListener) { containsTrainingTrigger = true; } } if (!containsTrainingTrigger) { // Hack to figure out which annotations the user is viewing. This obviously works only // if the user is viewing annotations through an AnnotationPageBase ... still not a // bad guess IPageRequestHandler handler = PageRequestHandlerTracker .getLastHandler(requestCycle); Page page = (Page) handler.getPage(); if (page instanceof AnnotationPageBase) { AnnotatorState state = ((AnnotationPageBase) page).getModelObject(); requestCycle.getListeners() .add(new TriggerTrainingTaskListener(state.getDocument())); } else { // Otherwise use the document from the event... mind that if there are multiple // events, we consider only the first one since after that the trigger listener // will be in the cycle and we do not add another one. // FIXME: This works as long as the user is working on a single document, but not if // the user is doing a bulk operation. If a bulk-operation is done, we get multiple // AfterCasWrittenEvent and we do not know which of them belongs to the document // which the user is currently viewing. requestCycle.getListeners() .add(new TriggerTrainingTaskListener(aEvent.getDocument().getDocument())); } } }
Example 6
Source File: AbstractContentAwareTransactionRequestCycleListener.java From wicket-orientdb with Apache License 2.0 | 4 votes |
/** * Is current 'transaction' in progress? * @param cycle {@link RequestCycle} * @return true - if we are within a transaction, false - if not */ public boolean isInProgress(RequestCycle cycle) { Boolean inProgress = cycle.getMetaData(IN_PROGRESS_KEY); return inProgress!=null?inProgress:false; }
Example 7
Source File: OMetricsRequestCycleListener.java From Orienteer with Apache License 2.0 | 4 votes |
@Override public void onEndRequest(RequestCycle cycle) { Histogram.Timer requestTimer = cycle.getMetaData(REQUESTS_HISTOGRAM_KEY); requestTimer.observeDuration(); }