use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.
the class AjaxProxy method addRequiredWebResources.
/**
* Adds the jsonrpc.js script to the head in the response if not already present and also adds a javascript proxy
* for the supplied bridge under the name "JSONRPC_<variableName>".
*
* @param res the response to write into
*/
@Override
protected void addRequiredWebResources(WOResponse res) {
addScriptResourceInHead(res, "jsonrpc.js");
NSMutableDictionary userInfo = ERXWOContext.contextDictionary();
String name = (String) valueForBinding("name");
String key = "JSONRPC_" + name;
Object oldValue = userInfo.objectForKey(key);
Object bridge = getBridgeBinding();
if (bridge == null) {
bridge = NSKeyValueCoding.NullValue;
}
if (oldValue == null) {
// add the javascript variable 'name' only if not already in the
// response
userInfo.setObjectForKey(bridge, key);
String jsonRpcJavascript;
if (booleanValueForBinding("lazy", false)) {
String varName = "_" + name;
jsonRpcJavascript = "function " + name + "(callback) { if (typeof " + varName + " == 'undefined') { " + varName + "=new JSONRpcClient(callback, '" + AjaxUtils.ajaxComponentActionUrl(context()) + "'); } else { callback(); } }";
} else {
jsonRpcJavascript = name + "=new JSONRpcClient('" + AjaxUtils.ajaxComponentActionUrl(context()) + "');";
}
ERXResponseRewriter.addScriptCodeInHead(res, context(), jsonRpcJavascript, key);
} else {
// was it referencing the same JSONRPCBridge object ?
if (bridge != oldValue) {
// well, it wasn't ... there is high chance of unexpected
// problem. just warn the user (programmer), that it might cause
// problem.
log.warn("JSONRPCProxy detected a conflict. You defined the javascript variable '{}' multiple times, and linked to differents proxy objects: <{}> and <{}>", name, bridge, oldValue);
}
}
}
use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.
the class ERXWOContext method contextDictionary.
public static NSMutableDictionary contextDictionary() {
if (observer == null) {
synchronized (ERXWOContext.class) {
if (observer == null) {
observer = new Observer();
NSNotificationCenter.defaultCenter().addObserver(observer, ERXUtilities.notificationSelector("applicationDidHandleRequest"), WOApplication.ApplicationDidDispatchRequestNotification, null);
}
}
}
NSMutableDictionary contextDictionary = ERXWOContext._contextDictionary();
if (contextDictionary == null) {
contextDictionary = new NSMutableDictionary();
ERXThreadStorage.takeValueForKey(contextDictionary, ERXWOContext.CONTEXT_DICTIONARY_KEY);
}
return contextDictionary;
}
use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.
the class ERXAjaxSession method savePageInPermanentCache.
/**
* Saves a page in the permanent cache. Overridden to not save in the super implementation's iVars but in our own.
*/
// FIXME: ak: as we save the perm pages under a lot of context IDs, we should have a way to actually limit the size...
// not sure how, though
@Override
public void savePageInPermanentCache(WOComponent wocomponent) {
if (overridePrivateCache) {
WOContext wocontext = context();
String contextID = wocontext.contextID();
log.debug("Saving page for contextID: {}", contextID);
NSMutableDictionary permanentPageCache = _permanentPageCache();
for (int i = WOApplication.application().permanentPageCacheSize(); _permanentContextIDArray.count() >= i; _permanentContextIDArray.removeObjectAtIndex(0)) {
String s1 = (String) _permanentContextIDArray.objectAtIndex(0);
WOComponent page = (WOComponent) permanentPageCache.removeObjectForKey(s1);
if (storesPageInfo()) {
pageInfoDictionary().removeObjectForKey(page);
}
}
permanentPageCache.setObjectForKey(wocomponent, contextID);
_permanentContextIDArray.addObject(contextID);
} else {
super.savePageInPermanentCache(wocomponent);
}
}
use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.
the class ERXApplication method _addAdditionalAdaptors.
/**
* Injects additional adaptors into the WOAdditionalAdaptors setting.
* Subclasses can extend this method, but should call super._addAdditionalAdaptors.
*
* @param additionalAdaptors the mutable adaptors array
*/
protected void _addAdditionalAdaptors(NSMutableArray<NSDictionary<String, Object>> additionalAdaptors) {
if (sslEnabled()) {
boolean sslAdaptorConfigured = false;
for (NSDictionary<String, Object> adaptor : additionalAdaptors) {
if (ERXSecureDefaultAdaptor.class.getName().equals(adaptor.objectForKey(WOProperties._AdaptorKey))) {
sslAdaptorConfigured = true;
}
}
ERXSecureDefaultAdaptor.checkSSLConfig();
if (!sslAdaptorConfigured) {
NSMutableDictionary<String, Object> sslAdaptor = new NSMutableDictionary<>();
sslAdaptor.setObjectForKey(ERXSecureDefaultAdaptor.class.getName(), WOProperties._AdaptorKey);
String sslHost = sslHost();
if (sslHost != null) {
sslAdaptor.setObjectForKey(sslHost, WOProperties._HostKey);
}
sslAdaptor.setObjectForKey(Integer.valueOf(sslPort()), WOProperties._PortKey);
additionalAdaptors.addObject(sslAdaptor);
}
}
}
use of com.webobjects.foundation.NSMutableDictionary in project wonder-slim by undur.
the class ERXRequest method mutableUserInfo.
public NSMutableDictionary<String, Object> mutableUserInfo() {
NSDictionary userInfo = userInfo();
NSMutableDictionary mutableUserInfo;
if (userInfo == null) {
mutableUserInfo = new NSMutableDictionary();
_userInfo = mutableUserInfo;
} else if (userInfo instanceof NSMutableDictionary) {
mutableUserInfo = (NSMutableDictionary) userInfo;
} else {
mutableUserInfo = userInfo.mutableClone();
_userInfo = mutableUserInfo;
}
return mutableUserInfo;
}
Aggregations