Function<ContextCreation> createContext = new Function<ContextCreation>() {
@Override
public void execute(final Control<ContextCreation> control) {
final String nameToken = control.getContext().getRequest().getNameToken();
final SecurityContext context = securityFramework.getSecurityContext(nameToken);
if(context==null || (context instanceof ReadOnlyContext)) // force re-creation if read-only fallback
{
securityFramework.createSecurityContext(nameToken, new AsyncCallback<SecurityContext>() {
@Override
public void onFailure(Throwable throwable) {
control.getContext().setError(throwable);
control.abort();
}
@Override
public void onSuccess(SecurityContext securityContext) {
control.proceed();
}
});
}
else
{
control.proceed();
}
}
};
Outcome<ContextCreation> outcome = new Outcome<ContextCreation>() {
@Override
public void onFailure(ContextCreation context) {
unlock();
Console.error("Failed to create security context", context.getError().getMessage());
}
@Override
public void onSuccess(final ContextCreation context) {
// unlock(); // remove?
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
final PlaceRequest placeRequest = context.getRequest();
DefaultPlaceManager.super.doRevealPlace(placeRequest, true);
eventBus.fireEvent(
new LHSHighlightEvent(placeRequest.getNameToken())
);
}