Search in sources :

Example 16 with NSMutableDictionary

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);
        }
    }
}
Also used : JSONObject(org.json.JSONObject) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Example 17 with NSMutableDictionary

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;
}
Also used : NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Example 18 with NSMutableDictionary

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);
    }
}
Also used : WOComponent(com.webobjects.appserver.WOComponent) WOContext(com.webobjects.appserver.WOContext) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Example 19 with NSMutableDictionary

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);
        }
    }
}
Also used : ERXWOString(er.extensions.components._private.ERXWOString) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Example 20 with NSMutableDictionary

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;
}
Also used : NSDictionary(com.webobjects.foundation.NSDictionary) NSMutableDictionary(com.webobjects.foundation.NSMutableDictionary)

Aggregations

NSMutableDictionary (com.webobjects.foundation.NSMutableDictionary)59 Enumeration (java.util.Enumeration)12 WOAssociation (com.webobjects.appserver.WOAssociation)10 WOComponent (com.webobjects.appserver.WOComponent)8 NSDictionary (com.webobjects.foundation.NSDictionary)7 NSMutableArray (com.webobjects.foundation.NSMutableArray)6 WOConstantValueAssociation (com.webobjects.appserver._private.WOConstantValueAssociation)5 NSArray (com.webobjects.foundation.NSArray)5 WODeclaration (com.webobjects.appserver._private.WODeclaration)4 WOHTMLCommentString (com.webobjects.appserver._private.WOHTMLCommentString)4 NoSuchElementException (java.util.NoSuchElementException)4 StringTokenizer (java.util.StringTokenizer)4 NSForwardException (com.webobjects.foundation.NSForwardException)2 ERXMutableURL (er.extensions.foundation.ERXMutableURL)2 MalformedURLException (java.net.MalformedURLException)2 JSONObject (org.json.JSONObject)2 WOActionResults (com.webobjects.appserver.WOActionResults)1 WOContext (com.webobjects.appserver.WOContext)1 WODynamicElementCreationException (com.webobjects.appserver._private.WODynamicElementCreationException)1 NSBundle (com.webobjects.foundation.NSBundle)1