use of com.webobjects.foundation.NSDictionary in project wonder-slim by undur.
the class ERXBrowserFactory method browserMatchingUserAgent.
/**
* Returns a shared browser object for a given <code>user-agent</code>
* string by parsing the string and retrieving the appropriate browser
* object, creating it if necessary.
* <p>
* Use this method to retrieve a browser instance from an existing
* user-agent string rather than a request object (e.g. you're
* recreating a browser instance from a past user-agent string). Once
* you get the browser object, you are responsible for calling {@link
* #retainBrowser retainBrowser} to keep it in the browser pool.
* <p>
* You are also required to call {@link #releaseBrowser releaseBrowser}
* to release the browser from the pool when it is no longer needed.
*
* @param ua - user agent string (e.g. from request headers)
* @return a shared browser object
*/
public ERXBrowser browserMatchingUserAgent(String ua) {
if (ua == null) {
return getBrowserInstance(ERXBrowser.UNKNOWN_BROWSER, ERXBrowser.UNKNOWN_VERSION, ERXBrowser.UNKNOWN_VERSION, ERXBrowser.UNKNOWN_PLATFORM, null);
}
ERXBrowser result = (ERXBrowser) _cache.get(ua);
if (result == null) {
String browserName = parseBrowserName(ua);
String version = parseVersion(ua);
String mozillaVersion = parseMozillaVersion(ua);
String platform = parsePlatform(ua);
NSDictionary userInfo = new NSDictionary(new Object[] { parseCPU(ua), parseGeckoVersion(ua) }, new Object[] { "cpu", "geckoRevision" });
result = getBrowserInstance(browserName, version, mozillaVersion, platform, userInfo);
_cache.put(ua, result);
}
return result;
}
use of com.webobjects.foundation.NSDictionary in project wonder-slim by undur.
the class ERXComponentRequestHandler method _dispatchWithPreparedSession.
private WOResponse _dispatchWithPreparedSession(WOSession aSession, WOContext aContext, NSDictionary someElements) {
WOComponent aPage = null;
WOResponse aResponse = null;
String aPageName = (String) someElements.objectForKey("wopage");
String oldContextID = aContext._requestContextID();
String oldSessionID = (String) someElements.objectForKey(WOApplication.application().sessionIdKey());
WOApplication anApplication = WOApplication.application();
boolean clearIDsInCookies = false;
if ((oldSessionID == null) || (oldContextID == null)) {
if ((aPageName == null) && (!aSession.storesIDsInCookies())) {
WORequest request = aContext.request();
String cookieHeader = request.headerForKey("cookie");
if ((cookieHeader != null) && (cookieHeader.length() > 0)) {
NSDictionary cookieDict = request.cookieValues();
if ((cookieDict.objectForKey(WOApplication.application().sessionIdKey()) != null) || (cookieDict.objectForKey(WOApplication.application().instanceIdKey()) != null)) {
clearIDsInCookies = true;
}
}
}
aPage = anApplication.pageWithName(aPageName, aContext);
} else {
aPage = _restorePageForContextID(oldContextID, aSession);
if (aPage == null) {
if (anApplication._isPageRecreationEnabled())
aPage = anApplication.pageWithName(aPageName, aContext);
else {
return anApplication.handlePageRestorationErrorInContext(aContext);
}
}
}
aContext._setPageElement(aPage);
aResponse = _dispatchWithPreparedPage(aPage, aSession, aContext, someElements);
if (anApplication.isPageRefreshOnBacktrackEnabled()) {
aResponse.disableClientCaching();
}
aSession._saveCurrentPage();
if ((clearIDsInCookies) && (!aSession.storesIDsInCookies())) {
aSession._clearCookieFromResponse(aResponse);
}
return aResponse;
}
use of com.webobjects.foundation.NSDictionary in project wonder-slim by undur.
the class ERXComponentRequestHandler method _handleRequest.
WOResponse _handleRequest(WORequest aRequest) {
WOContext aContext = null;
WOResponse aResponse;
NSDictionary requestHandlerValues = requestHandlerValuesForRequest(aRequest);
WOApplication anApplication = WOApplication.application();
String aSessionID = (String) requestHandlerValues.objectForKey(WOApplication.application().sessionIdKey());
if ((!anApplication.isRefusingNewSessions()) || (aSessionID != null)) {
String aSenderID = (String) requestHandlerValues.objectForKey("woeid");
String oldContextID = (String) requestHandlerValues.objectForKey("wocid");
WOStatisticsStore aStatisticsStore = anApplication.statisticsStore();
if (aStatisticsStore != null)
aStatisticsStore.applicationWillHandleComponentActionRequest();
try {
aContext = anApplication.createContextForRequest(aRequest);
aContext._setRequestContextID(oldContextID);
aContext._setSenderID(aSenderID);
anApplication.awake();
aResponse = _dispatchWithPreparedApplication(anApplication, aContext, requestHandlerValues);
NSNotificationCenter.defaultCenter().postNotification(WORequestHandler.DidHandleRequestNotification, aContext);
anApplication.sleep();
} catch (Exception exception) {
try {
NSLog.err.appendln("<" + getClass().getName() + ">: Exception occurred while handling request:\n" + exception.toString());
if (NSLog.debugLoggingAllowedForLevelAndGroups(1, 4L)) {
NSLog.debug.appendln(exception);
}
if (aContext == null)
aContext = anApplication.createContextForRequest(aRequest);
else {
aContext._putAwakeComponentsToSleep();
}
WOSession aSession = aContext._session();
aResponse = anApplication.handleException(exception, aContext);
if (aSession != null) {
try {
anApplication.saveSessionForContext(aContext);
anApplication.sleep();
} catch (Exception eAgain) {
NSLog.err.appendln("<WOApplication '" + anApplication.name() + "'>: Another Exception occurred while trying to clean the application:\n" + eAgain.toString());
if (NSLog.debugLoggingAllowedForLevelAndGroups(1, 4L))
NSLog.debug.appendln(eAgain);
}
}
} finally {
if ((aContext != null) && (aContext._session() != null))
anApplication.saveSessionForContext(aContext);
}
}
if (aResponse != null) {
aResponse._finalizeInContext(aContext);
}
if (aStatisticsStore != null) {
WOComponent aPage = aContext.page();
String aName = null;
if (aPage != null) {
aName = aPage.name();
}
aStatisticsStore.applicationDidHandleComponentActionRequestWithPageNamed(aName);
}
} else {
String newLocationURL = anApplication._newLocationForRequest(aRequest);
String contentString = "Sorry, your request could not immediately be processed. Please try this URL: <a href=\"" + newLocationURL + "\">" + newLocationURL + "</a>";
aResponse = anApplication.createResponseInContext(null);
WOResponse._redirectResponse(aResponse, newLocationURL, contentString);
aResponse._finalizeInContext(null);
}
return aResponse;
}
use of com.webobjects.foundation.NSDictionary in project wonder-slim by undur.
the class ERXStaticResourceRequestHandler method documentRoot.
private String documentRoot() {
if (_documentRoot == null) {
_documentRoot = ERXProperties.stringForKey("WODocumentRoot");
if (_documentRoot == null) {
NSDictionary dict = ERXUtilities.dictionaryFromPropertyList("WebServerConfig", "JavaWebObjects");
_documentRoot = (String) dict.objectForKey("DocumentRoot");
}
}
return _documentRoot;
}
use of com.webobjects.foundation.NSDictionary in project wonder-slim by undur.
the class WOStatsPage method _maxServedForDictionary.
protected long _maxServedForDictionary(NSDictionary aDictionary) {
long aMaxServedCount = 0;
NSDictionary aPage = null;
Enumeration aPageEnumerator = aDictionary.objectEnumerator();
while (aPageEnumerator.hasMoreElements()) {
aPage = (NSDictionary) aPageEnumerator.nextElement();
long newCount = ((Long) aPage.objectForKey("Served")).longValue();
aMaxServedCount += newCount;
}
return aMaxServedCount;
}
Aggregations