use of com.webobjects.foundation.NSDictionary in project wonder-slim by undur.
the class ERXAjaxApplication method takeValuesFromRequest.
/**
* Ajax links have a ?_u=xxx&2309482093 in the url which makes it look like a form submission to WebObjects.
* Therefore takeValues is called on every update even though many many updates aren't submits. This method
* checks to see if all you have is a _u or _r and an ismap (the #) param for form values. If so, it's not
* a form submission and takeValues can be skipped.
*
* @see com.webobjects.appserver.WOApplication#takeValuesFromRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)
*
* @param request
* the current request
* @param context
* the context
*/
@Override
public void takeValuesFromRequest(WORequest request, WOContext context) {
boolean shouldTakeValuesFromRequest = true;
if (!request.isMultipartFormData() && ERXAjaxApplication.isAjaxRequest(request)) {
NSDictionary formValues = request.formValues();
int formValuesCount = formValues.count();
if (formValuesCount == 2 && (formValues.containsKey(ERXAjaxApplication.KEY_UPDATE_CONTAINER_ID) || formValues.containsKey(ERXAjaxApplication.KEY_REPLACED)) && formValues.containsKey(WORequest._IsmapCoords)) {
shouldTakeValuesFromRequest = false;
}
}
if (shouldTakeValuesFromRequest) {
super.takeValuesFromRequest(request, context);
}
}
use of com.webobjects.foundation.NSDictionary in project wonder-slim by undur.
the class ERXApplication method handleException.
/**
* Overridden to log extra information about state when exception is handled.
*/
@Override
public WOResponse handleException(Exception exception, WOContext context) {
// We first want to test if we ran out of memory. If so we need to quit ASAP.
handlePotentiallyFatalException(exception);
// Not a fatal exception, business as usual.
final NSDictionary extraInfo = ERXUtilities.extraInformationForExceptionInContext(exception, context);
log.error("Exception caught: " + exception.getMessage() + "\nExtra info: " + NSPropertyListSerialization.stringFromPropertyList(extraInfo) + "\n", exception);
WOResponse response = super.handleException(exception, context);
response.setStatus(500);
return response;
}
use of com.webobjects.foundation.NSDictionary 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;
}
use of com.webobjects.foundation.NSDictionary in project wonder-slim by undur.
the class WOHelperFunctionParser method parseInlineAssociation.
protected void parseInlineAssociation(StringBuffer keyBuffer, StringBuffer valueBuffer, NSMutableDictionary bindings) throws WOHelperFunctionHTMLFormatException {
String key = keyBuffer.toString().trim();
String value = valueBuffer.toString().trim();
NSDictionary quotedStrings;
if (value.startsWith("\"")) {
value = value.substring(1);
if (value.endsWith("\"")) {
value = value.substring(0, value.length() - 1);
} else {
throw new WOHelperFunctionHTMLFormatException(valueBuffer + " starts with quote but does not end with one.");
}
if (value.startsWith("$")) {
value = value.substring(1);
if (value.endsWith("VALID")) {
value = value.replaceFirst("\\s*//\\s*VALID", "");
}
quotedStrings = new NSDictionary();
} else {
value = value.replaceAll("\\\\\\$", "\\$");
value = value.replaceAll("\\\"", "\"");
quotedStrings = new NSDictionary(value, "_WODP_0");
value = "_WODP_0";
}
} else {
quotedStrings = new NSDictionary();
}
WOAssociation association = WOHelperFunctionDeclarationParser._associationWithKey(value, quotedStrings);
bindings.setObjectForKey(association, key);
}
use of com.webobjects.foundation.NSDictionary in project wonder-slim by undur.
the class ERXStyleSheet method appendToResponse.
/**
* Appends the <link> tag, either by using the style sheet name and framework or by using the component content and then generating a link to it.
*/
@Override
public void appendToResponse(WOResponse originalResponse, WOContext wocontext) {
String styleSheetFrameworkName = styleSheetFrameworkName();
String styleSheetName = styleSheetName();
boolean isResourceStyleSheet = styleSheetName != null;
if (isResourceStyleSheet && ERXResponseRewriter.isResourceAddedToHead(wocontext, styleSheetFrameworkName, styleSheetName)) {
// Skip, because this has already been added ...
return;
}
// default to inline for ajax requests
boolean inline = booleanValueForBinding("inline", ERXAjaxApplication.isAjaxRequest(wocontext.request()));
WOResponse response = inline ? originalResponse : new WOResponse();
String href = styleSheetUrl();
if (href == null) {
String key = styleSheetKey();
ERXExpiringCache<String, WOResponse> cache = cache(session());
String md5;
WOResponse cachedResponse = cache.objectForKey(key);
if (cache.isStale(key) || ERXApplication.isDevelopmentModeSafe()) {
cachedResponse = new WOResponse();
super.appendToResponse(cachedResponse, wocontext);
// appendToResponse above will change the response of
// "wocontext" to "newresponse". When this happens during an
// Ajax request, it will lead to backtracking errors on
// subsequent requests, so restore the original response "r"
wocontext._setResponse(originalResponse);
cachedResponse.setHeader("text/css", "content-type");
cache.setObjectForKey(cachedResponse, key);
md5 = md5Hex(cachedResponse.contentString());
cachedResponse.setHeader(md5, "checksum");
}
md5 = cachedResponse.headerForKey("checksum");
NSDictionary<String, Object> query = new NSDictionary<>(md5, "checksum");
href = wocontext.directActionURLForActionNamed(Sheet.class.getName() + "/" + key, query, wocontext.request().isSecure(), 0, false);
}
response._appendContentAsciiString("<link");
if (styleSheetName != null && styleSheetName.toLowerCase().endsWith(".less")) {
response._appendTagAttributeAndValue("rel", "stylesheet/less", false);
} else {
response._appendTagAttributeAndValue("rel", "stylesheet", false);
}
response._appendTagAttributeAndValue("type", "text/css", false);
response._appendTagAttributeAndValue("href", href, false);
response._appendTagAttributeAndValue("media", mediaType(), false);
response._appendContentAsciiString("/>");
response.appendContentString("\n");
boolean inserted = true;
if (!inline) {
String stylesheetLink = response.contentString();
inserted = ERXResponseRewriter.insertInResponseBeforeHead(originalResponse, wocontext, stylesheetLink, ERXResponseRewriter.TagMissingBehavior.Inline);
}
if (inserted) {
if (isResourceStyleSheet) {
ERXResponseRewriter.resourceAddedToHead(wocontext, styleSheetFrameworkName, styleSheetName);
} else if (href != null) {
ERXResponseRewriter.resourceAddedToHead(wocontext, null, href);
}
}
}
Aggregations