/** * Resets the managed context. * * @param item Managed context to reset. * @param silent Silent flag. * @return True if change was accepted. */ private boolean resetItem(IManagedContext item, boolean silent) { try { localChangeBegin(item); item.reset(); return StringUtils.isEmpty(localChangeEnd(item, silent, true)); } catch (ContextException e) { return true; } }
/** * Updates managed contexts based on the marshaledContext. * * @param marshaledContext The marshaled context to process. * @param commit If true the pending contexts are committed. * @return Reason if context change rejected. */ /*package*/String setMarshaledContext(ContextItems marshaledContext, boolean commit) { StringBuilder reason = new StringBuilder(); for (IManagedContext managedContext : managedContexts) { try { if (managedContext.setContextItems(marshaledContext)) { localChangeBegin(managedContext); appendResponse(reason, localChangeEnd(managedContext, true, true)); } } catch (Exception e) { log.error("Error processing marshaled context change.", e); appendResponse(reason, e.toString()); } } if (commit) { commitContexts(reason.length() == 0, false); } return reason.toString(); }
/** * Resets the managed context. * * @param item Managed context to reset. * @param silent Silent flag. * @param callback Callback for polling. */ private void resetItem(IManagedContext<?> item, boolean silent, ISurveyCallback callback) { try { localChangeBegin(item); item.reset(); localChangeEnd(item, silent, true, callback); } catch (ContextException e) { execCallback(callback, e); } }
/** * Initializes the managed context. * * @param item Managed context to initialize. * @return True if change was accepted. */ private boolean initItem(IManagedContext item) { try { localChangeBegin(item); if (hasSubject(item.getContextName())) { item.setContextItems(contextItems); } else { item.init(); } return StringUtils.isEmpty(localChangeEnd(item)); } catch (ContextException e) { log.error("Error initializing context.", e); return false; } }
private void setMarshaledContext(ContextItems marshaledContext, Iterator<IManagedContext<?>> iter, ISurveyResponse response, ISurveyCallback callback) { if (iter.hasNext()) { IManagedContext<?> managedContext = iter.next(); try { if (managedContext.setContextItems(marshaledContext)) { localChangeBegin(managedContext); localChangeEnd(managedContext, true, true, aresponse -> { response.merge(aresponse); setMarshaledContext(marshaledContext, iter, response, callback); }); } } catch (Exception e) { log.error("Error processing marshaled context change.", e); response.reject(e.toString()); setMarshaledContext(marshaledContext, iter, response, callback); } } else { execCallback(callback, response); } }
/** * Initializes the managed context. * * @param item Managed context to initialize. * @param callback Callback to report subscriber responses. */ private void initItem(IManagedContext<?> item, ISurveyCallback callback) { try { localChangeBegin(item); if (hasSubject(item.getContextName())) { item.setContextItems(contextItems); } else { item.init(); } localChangeEnd(item, callback); } catch (ContextException e) { log.error("Error initializing context.", e); execCallback(callback, new SurveyResponse(e.toString())); } }