From e9302a01309dd657fe251d8823da79b76685289f Mon Sep 17 00:00:00 2001 From: Johann Werner Date: Fri, 9 Nov 2012 11:20:26 +0100 Subject: [PATCH] use ERXResponse and ERXHttpStatusCodes instead of WOResponse and plain ints --- .../monitor/application/AdminAction.java | 31 +++++++--------- .../monitor/application/DirectAction.java | 4 ++- .../Ajax/AjaxExample/Sources/PushExample.java | 5 ++- .../Sources/er/ajax/AjaxRemoteLogging.java | 3 +- .../Ajax/Sources/er/ajax/AjaxSessionPing.java | 11 +++--- .../_ajax/D2WAjaxEditAttachmentList.java | 4 +-- .../components/ERDragAndDropUpload.java | 9 ++--- .../er/directtoweb/ERD2WDirectAction.java | 8 ++--- .../er/directtoweb/ERD2WPageRunner.java | 4 +-- .../appserver/ERXDelayedRequestHandler.java | 5 ++- .../er/extensions/components/ERXIFrame.java | 4 ++- .../extensions/components/ERXSLTWrapper.java | 3 +- .../components/_private/ERXWOTextField.java | 3 +- .../components/html5/ERXWOInput.java | 3 +- .../components/javascript/ERXJavaScript.java | 3 +- .../er/extensions/foundation/ERXPatcher.java | 36 +++++++++---------- .../Sources/er/rest/ERXRestRequestNode.java | 4 +-- .../er/rest/routes/ERXRouteController.java | 3 +- .../Sources/er/excel/EGWrapper.java | 3 +- .../Sources/er/selenium/SeleniumAction.java | 7 ++-- .../er/selenium/SeleniumStartTesting.java | 9 ++--- .../er/selenium/SeleniumTestResults.java | 9 +++-- .../er/selenium/SeleniumTestRunnerProxy.java | 8 +++-- .../er/selenium/SeleniumTestSuite.java | 5 +-- .../webobjects/monitor/_private/MHost.java | 4 +-- 25 files changed, 96 insertions(+), 92 deletions(-) diff --git a/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/AdminAction.java b/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/AdminAction.java index 50ec153e50e..7c1c2ca5a3c 100644 --- a/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/AdminAction.java +++ b/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/AdminAction.java @@ -15,6 +15,9 @@ import com.webobjects.monitor._private.MObject; import com.webobjects.monitor._private.MSiteConfig; +import er.extensions.appserver.ERXHttpStatusCodes; +import er.extensions.appserver.ERXResponse; + /** *

* The following direct actions were added to Monitor. They might be useful for @@ -336,8 +339,7 @@ protected AdminApplicationsPage applicationsPage() { } public WOActionResults infoAction() { - WOResponse woresponse = new WOResponse(); - woresponse.setStatus(200); + ERXResponse woresponse = new ERXResponse(); String result = ""; for (Enumeration enumeration = instances.objectEnumerator(); enumeration.hasMoreElements();) { MInstance minstance = (MInstance) enumeration.nextElement(); @@ -378,9 +380,7 @@ public WOActionResults infoAction() { } public WOActionResults runningAction() { - WOResponse woresponse = new WOResponse(); - woresponse.setContent("YES"); - woresponse.setStatus(200); + ERXResponse woresponse = new ERXResponse("YES"); String num = (String) context().request().formValueForKey("num"); int numberOfInstancesRequested = -1; if (num != null && !num.equals("") && !num.equalsIgnoreCase("all")) { @@ -402,30 +402,26 @@ public WOActionResults runningAction() { } if ((numberOfInstancesRequested == -1 && instancesAlive < instances.count()) || instancesAlive < numberOfInstancesRequested) { woresponse.setContent("NO"); - woresponse.setStatus(417); + woresponse.setStatus(ERXHttpStatusCodes.EXPECTATION_FAILED); } return woresponse; } public WOActionResults stoppedAction() { - WOResponse woresponse = new WOResponse(); - woresponse.setContent("YES"); - woresponse.setStatus(200); + ERXResponse woresponse = new ERXResponse("YES"); for (Enumeration enumeration = instances.objectEnumerator(); enumeration.hasMoreElements();) { MInstance minstance = (MInstance) enumeration.nextElement(); if (minstance.state == MObject.DEAD) continue; woresponse.setContent("NO"); - woresponse.setStatus(417); + woresponse.setStatus(ERXHttpStatusCodes.EXPECTATION_FAILED); break; } return woresponse; } public WOActionResults bounceAction() { - WOResponse woresponse = new WOResponse(); - woresponse.setContent("OK"); - woresponse.setStatus(200); + ERXResponse woresponse = new ERXResponse("OK"); String bouncetype = (String) context().request().formValueForKey("bouncetype"); String maxwaitString = (String) context().request().formValueForKey("maxwait"); if (bouncetype == null || bouncetype == "" || bouncetype.equalsIgnoreCase("graceful")) { @@ -444,7 +440,7 @@ public WOActionResults bounceAction() { applicationsPage().bounceRolling(applications); } else { woresponse.setContent("Unknown bouncetype"); - woresponse.setStatus(406); + woresponse.setStatus(ERXHttpStatusCodes.NOT_ACCEPTABLE); } return woresponse; } @@ -611,7 +607,7 @@ private MSiteConfig siteConfig() { } public WOActionResults performActionNamed(String s) { - WOResponse woresponse = new WOResponse(); + WOResponse woresponse = new ERXResponse(); if (!siteConfig().isPasswordRequired() || siteConfig().compareStringWithPassword(context().request().stringFormValueForKey("pw"))) { try { WOActionResults woactionresults = performMonitorActionNamed(s); @@ -619,18 +615,17 @@ public WOActionResults performActionNamed(String s) { woresponse = (WOResponse) woactionresults; } else { woresponse.setContent("OK"); - woresponse.setStatus(200); } } catch (DirectActionException directactionexception) { woresponse.setStatus(directactionexception.status); woresponse.setContent(s + " action failed: " + directactionexception.getMessage()); } catch (Exception throwable) { - woresponse.setStatus(500); + woresponse.setStatus(ERXHttpStatusCodes.INTERNAL_ERROR); woresponse.setContent(s + " action failed: " + throwable.getMessage() + ". See Monitor's log for a stack trace."); throwable.printStackTrace(); } } else { - woresponse.setStatus(403); + woresponse.setStatus(ERXHttpStatusCodes.STATUS_FORBIDDEN); woresponse.setContent("Monitor is password protected - password missing or incorrect."); } return woresponse; diff --git a/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/DirectAction.java b/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/DirectAction.java index 13680b7a51b..4f0becdff1b 100644 --- a/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/DirectAction.java +++ b/Applications/JavaMonitor/Sources/com/webobjects/monitor/application/DirectAction.java @@ -27,6 +27,8 @@ import com.webobjects.monitor._private.MSiteConfig; import com.webobjects.monitor.application.WOTaskdHandler.ErrorCollector; +import er.extensions.appserver.ERXResponse; + public class DirectAction extends WODirectAction { public DirectAction(WORequest aRequest) { @@ -97,7 +99,7 @@ private NSDictionary historyEntry(MApplication app) { } public WOResponse statisticsAction() { - WOResponse response = new WOResponse(); + ERXResponse response = new ERXResponse(); String pw = context().request().stringFormValueForKey("pw"); if(siteConfig().compareStringWithPassword(pw)) { WOTaskdHandler handler = new WOTaskdHandler(new ErrorCollector() { diff --git a/Examples/Ajax/AjaxExample/Sources/PushExample.java b/Examples/Ajax/AjaxExample/Sources/PushExample.java index 36b688113df..866219cef54 100644 --- a/Examples/Ajax/AjaxExample/Sources/PushExample.java +++ b/Examples/Ajax/AjaxExample/Sources/PushExample.java @@ -10,6 +10,7 @@ import er.ajax.AjaxPushRequestHandler; import er.ajax.AjaxUtils; +import er.extensions.appserver.ERXResponse; public class PushExample extends WOComponent { @@ -70,8 +71,6 @@ public WOActionResults push() { System.out.println("PushExample.push: starting " + session().sessionID()); _pushSessionIDs.add(session().sessionID()); } - WOResponse response = new WOResponse(); - response.setContent("Sent some data"); - return response; + return new ERXResponse("Sent some data"); } } \ No newline at end of file diff --git a/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxRemoteLogging.java b/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxRemoteLogging.java index 3e05ff5cad3..5d837ceff49 100644 --- a/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxRemoteLogging.java +++ b/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxRemoteLogging.java @@ -12,6 +12,7 @@ import com.webobjects.foundation.NSDictionary; import er.extensions.appserver.ERXDirectAction; +import er.extensions.appserver.ERXResponse; /** * Allows you to log window.console JS messages from the browser to @@ -107,7 +108,7 @@ else if ("info".equalsIgnoreCase(level)) { else if ("debug".equalsIgnoreCase(level)) { log.debug(msg); } - return new WOResponse(); + return new ERXResponse(); } } diff --git a/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxSessionPing.java b/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxSessionPing.java index a82ec49e8d2..99d396df255 100644 --- a/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxSessionPing.java +++ b/Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxSessionPing.java @@ -3,6 +3,9 @@ import com.webobjects.appserver.*; import com.webobjects.foundation.*; +import er.extensions.appserver.ERXHttpStatusCodes; +import er.extensions.appserver.ERXResponse; + /** * Simple component to ping the session in the background. It can do two things. The first is * to execute JavaScript if the session is no longer valid. The default action is to close the window @@ -99,12 +102,12 @@ public Action(WORequest request) { * @return bare HTTP response with status set */ public WOActionResults pingSessionAction() { - WOResponse response = new WOResponse(); - boolean hasValidSession = existingSession() != null; - if (hasValidSession) { + ERXResponse response = new ERXResponse(); + if (existingSession() != null) { session(); + } else { + response.setStatus(ERXHttpStatusCodes.MULTIPLE_CHOICES); // CHECKME is that really the appropriate status code? } - response.setStatus(hasValidSession ? 200 : 300); return response; } diff --git a/Frameworks/Ajax/ERDivaLook/Sources/er/directtoweb/components/attachments/_ajax/D2WAjaxEditAttachmentList.java b/Frameworks/Ajax/ERDivaLook/Sources/er/directtoweb/components/attachments/_ajax/D2WAjaxEditAttachmentList.java index a52247840e2..38572e55044 100644 --- a/Frameworks/Ajax/ERDivaLook/Sources/er/directtoweb/components/attachments/_ajax/D2WAjaxEditAttachmentList.java +++ b/Frameworks/Ajax/ERDivaLook/Sources/er/directtoweb/components/attachments/_ajax/D2WAjaxEditAttachmentList.java @@ -2,10 +2,10 @@ import com.webobjects.appserver.WOActionResults; import com.webobjects.appserver.WOContext; -import com.webobjects.appserver.WOResponse; import com.webobjects.directtoweb.D2WComponent; import er.attachment.model.ERAttachment; +import er.extensions.appserver.ERXResponse; /** * D2W component for editing toMany ERAttachments @@ -42,6 +42,6 @@ public String onComplete() { // actions public WOActionResults removeAttachment() { object().removeObjectFromBothSidesOfRelationshipWithKey(attachment, propertyKey()); - return new WOResponse(); + return new ERXResponse(); } } diff --git a/Frameworks/BusinessLogic/ERAttachment/Sources/er/attachment/components/ERDragAndDropUpload.java b/Frameworks/BusinessLogic/ERAttachment/Sources/er/attachment/components/ERDragAndDropUpload.java index 2eb6304f05c..a158477095d 100644 --- a/Frameworks/BusinessLogic/ERAttachment/Sources/er/attachment/components/ERDragAndDropUpload.java +++ b/Frameworks/BusinessLogic/ERAttachment/Sources/er/attachment/components/ERDragAndDropUpload.java @@ -11,7 +11,6 @@ import com.webobjects.appserver.WOApplication; import com.webobjects.appserver.WOContext; import com.webobjects.appserver.WORequest; -import com.webobjects.appserver.WOResponse; import com.webobjects.eocontrol.EOEditingContext; import com.webobjects.foundation.NSArray; import com.webobjects.foundation.NSData; @@ -21,6 +20,8 @@ import er.attachment.model.ERAttachment; import er.attachment.model.ERDatabaseAttachment; import er.attachment.processors.ERAttachmentProcessor; +import er.extensions.appserver.ERXHttpStatusCodes; +import er.extensions.appserver.ERXResponse; import er.extensions.appserver.ERXWOContext; import er.extensions.components.ERXNonSynchronizingComponent; import er.extensions.eof.ERXQ; @@ -108,11 +109,7 @@ public WOActionResults invokeAction(WORequest request, WOContext context) { } else if (invokeAction) { invokeAction = false; willAccept = true; - WOResponse response = new WOResponse(); - //CHECKME 406 or 415? - response.setStatus(400); - response.setContent(localizer().localizedStringForKey("UnacceptableMimetype")); - return response; + return new ERXResponse(localizer().localizedStringForKey("UnacceptableMimetype"), ERXHttpStatusCodes.BAD_REQUEST); // CHECKME 406 or 415? } return super.invokeAction(request, context); } diff --git a/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/ERD2WDirectAction.java b/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/ERD2WDirectAction.java index fb89a1835b9..98e4d1a380d 100644 --- a/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/ERD2WDirectAction.java +++ b/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/ERD2WDirectAction.java @@ -13,7 +13,6 @@ import com.webobjects.appserver.WOActionResults; import com.webobjects.appserver.WOComponent; import com.webobjects.appserver.WORequest; -import com.webobjects.appserver.WOResponse; import com.webobjects.directtoweb.D2W; import com.webobjects.directtoweb.D2WContext; import com.webobjects.directtoweb.D2WPage; @@ -52,6 +51,8 @@ import er.directtoweb.pages.ERD2WQueryPage; import er.extensions.appserver.ERXApplication; import er.extensions.appserver.ERXDirectAction; +import er.extensions.appserver.ERXHttpStatusCodes; +import er.extensions.appserver.ERXResponse; import er.extensions.eof.ERXEC; import er.extensions.eof.ERXEOAccessUtilities; import er.extensions.eof.ERXEOControlUtilities; @@ -444,10 +445,7 @@ protected boolean allowPageConfiguration(String pageConfiguration) { * Returns a response with a 401 (access denied) message. Override this for something more user friendly. */ public WOActionResults forbiddenAction() { - WOResponse response = new WOResponse(); - response.setStatus(401); - response.setContent("Access denied"); - return response; + return new ERXResponse("Access denied", ERXHttpStatusCodes.UNAUTHORIZED); } /** diff --git a/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/ERD2WPageRunner.java b/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/ERD2WPageRunner.java index 44adb90a79c..1b3b294d41a 100644 --- a/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/ERD2WPageRunner.java +++ b/Frameworks/Core/ERDirectToWeb/Sources/er/directtoweb/ERD2WPageRunner.java @@ -6,7 +6,6 @@ import com.webobjects.appserver.WOComponent; import com.webobjects.appserver.WOContext; -import com.webobjects.appserver.WOResponse; import com.webobjects.appserver.WOSession; import com.webobjects.directtoweb.ConfirmPageInterface; import com.webobjects.directtoweb.D2W; @@ -18,6 +17,7 @@ import com.webobjects.eocontrol.EOEditingContext; import com.webobjects.foundation.NSArray; +import er.extensions.appserver.ERXResponse; import er.extensions.appserver.ERXSession; import er.extensions.appserver.ERXWOContext; import er.extensions.eof.ERXEC; @@ -82,7 +82,7 @@ public void createPages() { } else { log.info("Unsupported: " + pageName + " -> " + page.name()); } - page.appendToResponse(new WOResponse(), context); + page.appendToResponse(new ERXResponse(), context); } finally { ec.unlock(); } diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/appserver/ERXDelayedRequestHandler.java b/Frameworks/Core/ERExtensions/Sources/er/extensions/appserver/ERXDelayedRequestHandler.java index 37781a77d9c..0bbfbdaff7d 100644 --- a/Frameworks/Core/ERExtensions/Sources/er/extensions/appserver/ERXDelayedRequestHandler.java +++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/appserver/ERXDelayedRequestHandler.java @@ -240,8 +240,7 @@ public WOResponse handleRequest(final WORequest request) { if (url == null) { return createErrorResponse(request); } - response = new WOResponse(); - response.setStatus(302); + response = new ERXResponse(ERXHttpStatusCodes.FOUND); response.setHeader(url, "location"); // refresh entry, so it doesn't time out _urls.setObjectForKey(url, id); @@ -392,7 +391,7 @@ protected String cssUrl(WORequest request) { * @param url */ protected WOResponse createRefreshResponse(WORequest request, String url) { - WOResponse result = new WOResponse(); + ERXResponse result = new ERXResponse(); result.setHeader(refresh() + "; url=" + url + "\"", "refresh"); // ak: create a simple template result.appendContentString("\n\n\n"); diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/components/ERXIFrame.java b/Frameworks/Core/ERExtensions/Sources/er/extensions/components/ERXIFrame.java index 3be4a96b551..c26381bfb79 100644 --- a/Frameworks/Core/ERExtensions/Sources/er/extensions/components/ERXIFrame.java +++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/components/ERXIFrame.java @@ -11,6 +11,8 @@ import com.webobjects.appserver._private.WOHTMLDynamicElement; import com.webobjects.foundation.NSDictionary; +import er.extensions.appserver.ERXResponse; + /** * IFRAME that can use its own contents to render when none of the other * bindings are supplied. Makes page-writing a lot easier as you don't need an @@ -51,7 +53,7 @@ public WOActionResults invokeAction(WORequest request, WOContext context) { else if (_action != null) { return (WOActionResults) _action.valueInComponent(component); } else { - WOResponse response = new WOResponse(); + ERXResponse response = new ERXResponse(); //AK: we might want to be able to set this... response.appendContentString(""); response.appendContentString(""); diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/components/ERXSLTWrapper.java b/Frameworks/Core/ERExtensions/Sources/er/extensions/components/ERXSLTWrapper.java index 473225a503b..55bcd19a3e1 100644 --- a/Frameworks/Core/ERExtensions/Sources/er/extensions/components/ERXSLTWrapper.java +++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/components/ERXSLTWrapper.java @@ -40,6 +40,7 @@ import com.webobjects.foundation.NSData; import com.webobjects.foundation.NSForwardException; +import er.extensions.appserver.ERXResponse; import er.extensions.foundation.ERXFileUtilities; import er.extensions.foundation.ERXSimpleTemplateParser; @@ -168,7 +169,7 @@ public InputSource resolveEntity(String arg0, String arg1) throws SAXException, public void appendToResponse(WOResponse response, WOContext context) { start = System.currentTimeMillis(); current = start; if (isEnabled()) { - WOResponse newResponse = new WOResponse(); + ERXResponse newResponse = new ERXResponse(); newResponse.setContentEncoding(response.contentEncoding()); super.appendToResponse(newResponse, context); diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/components/_private/ERXWOTextField.java b/Frameworks/Core/ERExtensions/Sources/er/extensions/components/_private/ERXWOTextField.java index f22b9b1bc32..fff342d57b3 100644 --- a/Frameworks/Core/ERExtensions/Sources/er/extensions/components/_private/ERXWOTextField.java +++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/components/_private/ERXWOTextField.java @@ -19,6 +19,7 @@ import com.webobjects.foundation.NSTimeZone; import com.webobjects.foundation.NSTimestampFormatter; +import er.extensions.appserver.ERXResponse; import er.extensions.appserver.ERXSession; import er.extensions.formatters.ERXNumberFormatter; import er.extensions.formatters.ERXTimestampFormatter; @@ -265,7 +266,7 @@ public String toString() { * Overridden to make output XML compatible. */ public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = ERXPatcher.DynamicElementsPatches.cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = ERXPatcher.DynamicElementsPatches.cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); ERXPatcher.DynamicElementsPatches.processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/components/html5/ERXWOInput.java b/Frameworks/Core/ERExtensions/Sources/er/extensions/components/html5/ERXWOInput.java index 3f08f611643..92059311e44 100644 --- a/Frameworks/Core/ERExtensions/Sources/er/extensions/components/html5/ERXWOInput.java +++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/components/html5/ERXWOInput.java @@ -10,6 +10,7 @@ import com.webobjects.appserver._private.WOInput; import com.webobjects.foundation.NSDictionary; +import er.extensions.appserver.ERXResponse; import er.extensions.foundation.ERXKeyValueCodingUtilities; import er.extensions.foundation.ERXPatcher; @@ -104,7 +105,7 @@ public void takeValuesFromRequest(WORequest worequest, WOContext wocontext) { */ @Override public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = ERXPatcher.DynamicElementsPatches.cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = ERXPatcher.DynamicElementsPatches.cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); ERXPatcher.DynamicElementsPatches.processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/components/javascript/ERXJavaScript.java b/Frameworks/Core/ERExtensions/Sources/er/extensions/components/javascript/ERXJavaScript.java index 206f5867aa9..eb8a7873498 100644 --- a/Frameworks/Core/ERExtensions/Sources/er/extensions/components/javascript/ERXJavaScript.java +++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/components/javascript/ERXJavaScript.java @@ -20,6 +20,7 @@ import er.extensions.appserver.ERXApplication; import er.extensions.appserver.ERXResourceManager; +import er.extensions.appserver.ERXResponse; import er.extensions.appserver.ERXResponseRewriter; import er.extensions.foundation.ERXExpiringCache; import er.extensions.foundation.ERXProperties; @@ -161,7 +162,7 @@ else if (ERXResourceManager._shouldGenerateCompleteResourceURL(wocontext)) { boolean render = cache.isStale(key); render |= ERXApplication.isDevelopmentModeSafe(); if(render) { - WOResponse newresponse = new WOResponse(); + WOResponse newresponse = new ERXResponse(); super.appendChildrenToResponse(newresponse, wocontext); newresponse.setHeader("application/x-javascript", "content-type"); cache.setObjectForKey(newresponse, key); diff --git a/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXPatcher.java b/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXPatcher.java index c43899b50e5..9d3060453c5 100644 --- a/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXPatcher.java +++ b/Frameworks/Core/ERExtensions/Sources/er/extensions/foundation/ERXPatcher.java @@ -187,7 +187,7 @@ protected void _appendValueAttributeToResponse(WOResponse response, WOContext co } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); @@ -236,7 +236,7 @@ protected void _appendValueAttributeToResponse(WOResponse response, WOContext co } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); @@ -258,7 +258,7 @@ public void appendAttributesToResponse(WOResponse woresponse, WOContext wocontex } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, null); @@ -280,7 +280,7 @@ public void appendAttributesToResponse(WOResponse woresponse, WOContext wocontex } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, null); @@ -302,7 +302,7 @@ public void appendAttributesToResponse(WOResponse woresponse, WOContext wocontex } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, null); @@ -346,7 +346,7 @@ protected void appendConstantAttributesToResponse(WOResponse woresponse, WOConte } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); @@ -385,7 +385,7 @@ protected void _appendNameAttributeToResponse(WOResponse woresponse, WOContext w } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); @@ -427,7 +427,7 @@ protected void _appendNameAttributeToResponse(WOResponse woresponse, WOContext w } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); @@ -470,7 +470,7 @@ protected void _appendValueAttributeToResponse(WOResponse response, WOContext co } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); @@ -557,7 +557,7 @@ protected void _appendNameAttributeToResponse(WOResponse woresponse, WOContext w } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); @@ -642,7 +642,7 @@ protected void _appendNameAttributeToResponse(WOResponse woresponse, WOContext w } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); @@ -664,7 +664,7 @@ protected void _appendNameAttributeToResponse(WOResponse woresponse, WOContext w } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); @@ -749,7 +749,7 @@ protected void _appendNameAttributeToResponse(WOResponse woresponse, WOContext w } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); @@ -776,7 +776,7 @@ protected void _appendNameAttributeToResponse(WOResponse woresponse, WOContext w } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); @@ -813,7 +813,7 @@ protected void _appendNameAttributeToResponse(WOResponse woresponse, WOContext w } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); @@ -840,7 +840,7 @@ protected void _appendNameAttributeToResponse(WOResponse woresponse, WOContext w } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); @@ -877,7 +877,7 @@ protected void _appendNameAttributeToResponse(WOResponse woresponse, WOContext w } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); @@ -899,7 +899,7 @@ protected void _appendNameAttributeToResponse(WOResponse woresponse, WOContext w } public void appendToResponse(WOResponse woresponse, WOContext wocontext) { - WOResponse newResponse = cleanupXHTML ? new WOResponse() : woresponse; + WOResponse newResponse = cleanupXHTML ? new ERXResponse() : woresponse; super.appendToResponse(newResponse, wocontext); processResponse(this, newResponse, wocontext, 0, nameInContext(wocontext, wocontext.component())); diff --git a/Frameworks/EOF/ERRest/Sources/er/rest/ERXRestRequestNode.java b/Frameworks/EOF/ERRest/Sources/er/rest/ERXRestRequestNode.java index 4a91a9a522c..4bd8bbf6c7c 100644 --- a/Frameworks/EOF/ERRest/Sources/er/rest/ERXRestRequestNode.java +++ b/Frameworks/EOF/ERRest/Sources/er/rest/ERXRestRequestNode.java @@ -13,7 +13,6 @@ import org.apache.log4j.Logger; -import com.webobjects.appserver.WOResponse; import com.webobjects.eoaccess.EOEntityClassDescription; import com.webobjects.eocontrol.EOClassDescription; import com.webobjects.eocontrol.EOEnterpriseObject; @@ -24,6 +23,7 @@ import com.webobjects.foundation.NSMutableArray; import com.webobjects.foundation.NSMutableDictionary; +import er.extensions.appserver.ERXResponse; import er.extensions.eof.ERXKey; import er.extensions.eof.ERXKeyFilter; import er.extensions.foundation.ERXArrayUtilities; @@ -1072,7 +1072,7 @@ public String toString(ERXRestFormat format, ERXRestContext context) { * @return a string representation of this request node using the given IERXRestWriter */ public String toString(IERXRestWriter writer, ERXRestFormat.Delegate delegate, ERXRestContext context) { - WOResponse octopusHair = new WOResponse(); + ERXResponse octopusHair = new ERXResponse(); writer.appendToResponse(this, new ERXWORestResponse(octopusHair), delegate, context); return octopusHair.contentString(); } diff --git a/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java b/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java index 786b65ed949..ce5b1fb1c93 100644 --- a/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java +++ b/Frameworks/EOF/ERRest/Sources/er/rest/routes/ERXRouteController.java @@ -38,6 +38,7 @@ import er.extensions.appserver.ERXHttpStatusCodes; import er.extensions.appserver.ERXRequest; +import er.extensions.appserver.ERXResponse; import er.extensions.eof.ERXDatabaseContextDelegate.ObjectNotAvailableException; import er.extensions.eof.ERXEC; import er.extensions.eof.ERXKey; @@ -1739,7 +1740,7 @@ protected long accessControlMaxAage() { * @return the response */ public WOActionResults optionsAction() throws Throwable { - WOResponse response = new WOResponse(); + ERXResponse response = new ERXResponse(); String accessControlAllowOrigin = accessControlAllowOrigin(); if (accessControlAllowOrigin != null) { response.setHeader(accessControlAllowOrigin, "Access-Control-Allow-Origin"); diff --git a/Frameworks/Excel/ExcelGenerator/Sources/er/excel/EGWrapper.java b/Frameworks/Excel/ExcelGenerator/Sources/er/excel/EGWrapper.java index b69ed9766df..f0712a614b0 100644 --- a/Frameworks/Excel/ExcelGenerator/Sources/er/excel/EGWrapper.java +++ b/Frameworks/Excel/ExcelGenerator/Sources/er/excel/EGWrapper.java @@ -12,6 +12,7 @@ import com.webobjects.foundation.NSDictionary; import com.webobjects.foundation.NSForwardException; +import er.extensions.appserver.ERXResponse; import er.extensions.components.ERXComponentUtilities; import er.extensions.components.ERXNonSynchronizingComponent; @@ -83,7 +84,7 @@ public void setFonts(NSDictionary value) { @Override public void appendToResponse(WOResponse response, WOContext context) { if (isEnabled()) { - WOResponse newResponse = new WOResponse(); + ERXResponse newResponse = new ERXResponse(); super.appendToResponse(newResponse, context); diff --git a/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumAction.java b/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumAction.java index 959c0673f47..ddda14e7399 100644 --- a/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumAction.java +++ b/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumAction.java @@ -35,6 +35,7 @@ import com.webobjects.foundation.NSTimestamp; import er.extensions.appserver.ERXDirectAction; +import er.extensions.appserver.ERXResponse; /** * Default handler class, gets replaced by the startup process. @@ -69,7 +70,7 @@ protected void resetSession(WOResponse response) { protected WOResponse dictionaryResponse(NSDictionary dict) { - WOResponse response = new WOResponse(); + ERXResponse response = new ERXResponse(); response.appendContentString(""); for (Enumeration e = dict.keyEnumerator(); e.hasMoreElements();) { Object key = e.nextElement(); @@ -81,9 +82,7 @@ protected WOResponse dictionaryResponse(NSDictionary dict) { } protected WOResponse stringResponse(String s) { - WOResponse response = new WOResponse(); - response.appendContentString(s); - return response; + return new ERXResponse(s); } // @Deprecated diff --git a/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumStartTesting.java b/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumStartTesting.java index 721fb064414..4596dec174c 100644 --- a/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumStartTesting.java +++ b/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumStartTesting.java @@ -34,6 +34,9 @@ import com.webobjects.appserver.WOResponse; import com.webobjects.foundation.NSSelector; +import er.extensions.appserver.ERXHttpStatusCodes; +import er.extensions.appserver.ERXResponse; + /** * DirectAction that starts testing. * Has wa/SeleniumStartTesting, wa/SeleniumStartTesting/run and wa/SeleniumStartTesting/edit. @@ -81,9 +84,7 @@ private WOActionResults redirect(String url) { } private WOActionResults html(String url) { - WOResponse response = new WOResponse(); - response.appendContentString("go"); - return response; + return new ERXResponse("go"); } private WOActionResults result(String suite, boolean edit) { @@ -104,7 +105,7 @@ public WOActionResults editAction() { public WOActionResults performActionNamed(String anActionName) { if(!ERSelenium.testsEnabled()) { - return new WOResponse(); + return new ERXResponse(ERXHttpStatusCodes.STATUS_FORBIDDEN); } if("default".equals(anActionName)) { anActionName = null; diff --git a/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumTestResults.java b/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumTestResults.java index 64684772621..18ee2721f68 100644 --- a/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumTestResults.java +++ b/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumTestResults.java @@ -31,10 +31,11 @@ import com.webobjects.appserver.WOActionResults; import com.webobjects.appserver.WODirectAction; import com.webobjects.appserver.WORequest; -import com.webobjects.appserver.WOResponse; import com.webobjects.foundation.NSArray; import com.webobjects.foundation.NSComparator; +import er.extensions.appserver.ERXHttpStatusCodes; +import er.extensions.appserver.ERXResponse; import er.extensions.foundation.ERXFileUtilities; import er.extensions.foundation.ERXProperties; @@ -88,9 +89,7 @@ protected WOActionResults processReport(String filename) { } } - WOResponse response = new WOResponse(); - response.appendContentString(report()); - return response; + return new ERXResponse(report()); } public WOActionResults defaultAction() { @@ -99,7 +98,7 @@ public WOActionResults defaultAction() { public WOActionResults performActionNamed(String actionName) { if(!ERSelenium.testsEnabled()) { - return new WOResponse(); + return new ERXResponse(ERXHttpStatusCodes.STATUS_FORBIDDEN); } if (actionName.equals("default")) return defaultAction(); diff --git a/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumTestRunnerProxy.java b/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumTestRunnerProxy.java index b48ea6dd038..55b865ca535 100644 --- a/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumTestRunnerProxy.java +++ b/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumTestRunnerProxy.java @@ -37,6 +37,8 @@ import com.webobjects.foundation.NSMutableDictionary; import com.webobjects.foundation.NSNotificationCenter; +import er.extensions.appserver.ERXHttpStatusCodes; +import er.extensions.appserver.ERXResponse; import er.extensions.foundation.ERXFileUtilities; /** @@ -58,7 +60,7 @@ public SeleniumTestRunnerProxy() { // @Override public WOResponse handleRequest(WORequest request) { if(!ERSelenium.testsEnabled()) { - return new WOResponse(); + return new ERXResponse(ERXHttpStatusCodes.STATUS_FORBIDDEN); } NSArray pathElements = request.requestHandlerPathArray(); @@ -75,7 +77,7 @@ public WOResponse handleRequest(WORequest request) { log.debug("Processing file '" + filePath + "'"); /* - * Syncrhonization mistakes are possible here, but not fatal at all. + * Synchronization mistakes are possible here, but not fatal at all. * At the worst case the file will be read 2-or-more times instead of 1 (if process 1 * checks that the file is not cached and process 2 does the same check before * process 1 has updated the cache). @@ -109,7 +111,7 @@ public WOResponse handleRequest(WORequest request) { } } - WOResponse response = new WOResponse(); + ERXResponse response = new ERXResponse(); response.setHeader(cachedFile.mimeType, "content-type"); response.setContent(cachedFile.data); diff --git a/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumTestSuite.java b/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumTestSuite.java index f0822b6b3ec..befb6d6c21b 100644 --- a/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumTestSuite.java +++ b/Frameworks/Misc/ERSelenium/Sources/er/selenium/SeleniumTestSuite.java @@ -26,8 +26,9 @@ import com.webobjects.appserver.WOActionResults; import com.webobjects.appserver.WODirectAction; import com.webobjects.appserver.WORequest; -import com.webobjects.appserver.WOResponse; +import er.extensions.appserver.ERXHttpStatusCodes; +import er.extensions.appserver.ERXResponse; import er.extensions.foundation.ERXStringUtilities; /** @@ -47,7 +48,7 @@ public WOActionResults defaultAction() { // @Override public WOActionResults performActionNamed(String anActionName) { if(!ERSelenium.testsEnabled()) { - return new WOResponse(); + return new ERXResponse(ERXHttpStatusCodes.STATUS_FORBIDDEN); } if (anActionName.equals("default")) { return defaultAction(); diff --git a/Frameworks/Misc/JavaMonitorFramework/Sources/com/webobjects/monitor/_private/MHost.java b/Frameworks/Misc/JavaMonitorFramework/Sources/com/webobjects/monitor/_private/MHost.java index 4c44fb2554c..2c4b72b7063 100644 --- a/Frameworks/Misc/JavaMonitorFramework/Sources/com/webobjects/monitor/_private/MHost.java +++ b/Frameworks/Misc/JavaMonitorFramework/Sources/com/webobjects/monitor/_private/MHost.java @@ -31,6 +31,7 @@ import com.webobjects.foundation.NSMutableDictionary; import com.webobjects.foundation._NSThreadsafeMutableArray; +import er.extensions.appserver.ERXResponse; import er.extensions.foundation.ERXProperties; public class MHost extends MObject { @@ -382,8 +383,7 @@ public WOResponse sendRequestToWotaskd(WORequest aRequest, boolean willChange, b if (willChange) { _siteConfig.hostErrorArray.addObjectIfAbsent(this); } - aResponse = new WOResponse(); - aResponse.setContent(errorResponse); + aResponse = new ERXResponse(errorResponse); } else { // if we successfully synced, clear the error dictionary if (isSync && isAvailable) {