Skip to content

Commit

Permalink
remove code for WO5.3 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
darkv committed Dec 2, 2012
1 parent 49d508c commit acd5f73
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 70 deletions.
26 changes: 5 additions & 21 deletions Frameworks/Ajax/Ajax/Sources/er/ajax/AjaxResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,37 +60,21 @@ public WOResponse generateResponse() {
String originalSenderID = _context.senderID();
_context._setSenderID("");
try {
CharSequence content;
//AK: don't ask...
// MS: 5.3 vs 5.4 field type of _content
if (((Object)_content) instanceof StringBuffer) {
content = (StringBuffer)(Object)_content;
ERXKeyValueCodingUtilities.takePrivateValueForKey(this, new StringBuffer(), "_content");
} else {
content = (StringBuilder)(Object) _content;
ERXKeyValueCodingUtilities.takePrivateValueForKey(this, new StringBuilder(), "_content");
}
CharSequence originalContent = _content;
_content = new StringBuilder();
NSMutableDictionary userInfo = AjaxUtils.mutableUserInfo(_request);
userInfo.setObjectForKey(Boolean.TRUE, AjaxResponse.AJAX_UPDATE_PASS);
WOActionResults woactionresults = WOApplication.application().invokeAction(_request, _context);
_content.append(content);
_content.append(originalContent);
if (_responseAppenders != null) {
Enumeration responseAppendersEnum = _responseAppenders.objectEnumerator();
while (responseAppendersEnum.hasMoreElements()) {
AjaxResponseAppender responseAppender = (AjaxResponseAppender) responseAppendersEnum.nextElement();
responseAppender.appendToResponse(this, _context);
}
}
int length;
if (((Object)_content) instanceof StringBuffer) {
StringBuffer buffer = (StringBuffer)(Object)_content;
length = buffer.length();
} else {
StringBuilder builder = (StringBuilder)(Object) _content;
length = builder.length();
}
if (length == 0) {
setStatus(HTTP_STATUS_INTERNAL_ERROR);
if (_contentLength() == 0) {
setStatus(HTTP_STATUS_INTERNAL_ERROR);
Ajax.log.warn("You performed an Ajax update, but no response was generated. A common cause of this is that you spelled your updateContainerID wrong. You specified a container ID '" + AjaxUpdateContainer.updateContainerID(_request) + "'.");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,19 @@ public CCSubmitLink(WOContext context) {
super(context);
}

@SuppressWarnings("deprecation")
@Override
public WOActionResults invokeAction(WORequest request, WOContext context) {
String formValue = (String) request.formValueForKey(fieldName());
if (fieldName().equals(formValue)) {
// Tell context that an action was performed. If this is
// not done, the form's default action will be called also.
// *note* Uses undocumented method of WOContext.
//
// deprecated call required to maintain WO5.3 compatibility.
// change to context.setActionInvoked(true) once move to
// WO5.4+ is complete -davidleber
context.setActionInvoked(true);
}
return super.invokeAction(request, context);
}

@Override
public void appendToResponse(WOResponse response, WOContext context) {
// Check if the link is in a form so we know if we need to
// use the link and a hidden field to submit the form.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public EOAttribute anyAttributeNamed(String name) {
* @see com.webobjects.eoaccess.EOEntity#hasExternalName()
* @since 5.4.1
*/
//@Override introduced with 5.4.1
@Override
public boolean hasExternalName() {
// (ldeck) radar://6592526 fix for 5.4.3 regression which assumed that any parent entity that is abstract has no external name!
return externalName() != null && externalName().trim().length() > 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,36 +67,11 @@
* @author ldeck
*/
public class ERXModel extends EOModel {
public static Object _ERXGlobalModelLock;
// Expose EOModel._EOGlobalModelLock so that ERXModelGroup can lock on it
public static Object _ERXGlobalModelLock = EOModel._EOGlobalModelLock;

private static final Logger log = Logger.getLogger(ERXModel.class);

static {
// Expose EOModel._EOGlobalModelLock so that ERXModelGroup can lock on it
try {
_ERXGlobalModelLock = EOModel._EOGlobalModelLock;
}
catch (NoSuchFieldError e) {
// MS: It just so happens that this occurs really early on in the startup process, and this API changed in WO 5.3 vs WO 5.4. We catch this
// failure explicitly and give the user a slightly better error message.
try {
String eomodelLockClassName = EOModel.class.getDeclaredField("_EOGlobalModelLock").getType().getSimpleName();
if ("ReentrantLock".equals(eomodelLockClassName)) {
throw new RuntimeException("You're using WebObjects 5.4 with the WebObjects 5.3 version of Project Wonder. You need to download the 5.4 version of Project Wonder for your application to work properly.");
}
else if ("NSRecursiveLock".equals(eomodelLockClassName)) {
throw new RuntimeException("You're using WebObjects 5.3 with the WebObjects 5.4 version of Project Wonder. You need to download the 5.3 version of Project Wonder for your application to work properly.");
}
else {
throw new RuntimeException("You have the wrong version of Project Wonder for the version of WebObjects that you're using. You need to download the appropriate version of Project Wonder for your application to work properly.");
}
}
catch (NoSuchFieldException e2) {
throw e;
}
}

}
/**
* Utility to add attributes to the prototype cache. As the attributes are chosen by name, replace already
* existing ones.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ public void run() {
* Creates the request object for this loop. Calls _createRequest(). For WO
* 5.3.
*/
@SuppressWarnings("all") // Suppress @Override warning for 5.4
@Deprecated
public WORequest createRequest(String aMethod, String aURL, String anHTTPVersion, NSDictionary someHeaders, NSData aContent, NSDictionary someInfo) {
return _createRequest(aMethod, aURL, anHTTPVersion, someHeaders, aContent, someInfo);
}
Expand All @@ -1439,8 +1439,7 @@ public WORequest createRequest(String aMethod, String aURL, String anHTTPVersion
* Creates the request object for this loop. Calls _createRequest(). For WO
* 5.4.
*/
@SuppressWarnings("all")
// Suppress @Override warning for 5.3
@Override
public WORequest createRequest(String method, String aurl, String anHTTPVersion, Map<String, ? extends List<String>> someHeaders, NSData content, Map<String, Object> someInfo) {
return _createRequest(method, aurl, anHTTPVersion, (someHeaders != null ? new NSDictionary<String, Object>(someHeaders, true) : null), content, (someInfo != null ? new NSDictionary<String, Object>(someInfo, true) : null));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ERXAjaxContext(WORequest request) {
super(request);
}

// @Override no override for 5.4/5.3 compatibility
@Override
public boolean wasFormSubmitted() {
return _wasFormSubmitted();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,18 +307,6 @@ public void appendToResponse(WOResponse woresponse, WOContext wocontext) {
woresponse.appendContentString(newResponse.contentString());
}
}

// WO 5.4: 5.4 already does this, but for 5.3, if you want to use WOImage's with
// PDF generation, you need XHTML output
protected void _appendOpenTagToResponse(WOResponse response, WOContext context) {
response.appendContentCharacter('<');
response.appendContentString(elementName());
appendAttributesToResponse(response, context);
if(!hasContent() || ERXResponse.isXHTML(response)) { // CHECKME do we need to check isXHTML?
response.appendContentString(" /");
}
response.appendContentCharacter('>');
}
}

public static class ActiveImage extends WOActiveImage {
Expand Down

0 comments on commit acd5f73

Please sign in to comment.