Skip to content

Commit

Permalink
Merge pull request #336 from darkv/wo54_2_patch
Browse files Browse the repository at this point in the history
Remove pre WO 5.4 code (updated)
  • Loading branch information
Pascal Robert committed Dec 2, 2012
2 parents fab851e + b5c6b78 commit be6a524
Show file tree
Hide file tree
Showing 38 changed files with 105 additions and 572 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 @@ -241,14 +241,8 @@ public NSDictionary primaryKeyFromRequest(EOEditingContext ec, String entityName

public WOComponent previousPageFromRequest() {
String cid = context().request().stringFormValueForKey(contextIDKey);
if(cid == null) return context().page();
WOComponent comp = session().restorePageForContextID(cid);
// (ak) we need to put the component to sleep again
// Michael Bushkov: WO5.4.3 tracks all awakened components so no need to call this manually
if(comp != null && !ERXApplication.isWO54()) {
comp._sleepInContext(comp.context());
}
return comp;
if (cid == null) return context().page();
return session().restorePageForContextID(cid);
}

public String keyPathFromRequest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -741,19 +741,6 @@ protected void uniqueQualifiers(NSArray rules) {
}
}

//AK: this is probably never called in WO > 5.2
public Vector modelFilesInBundles () {
Vector modelFiles = super.modelFilesInBundles();
if (!_hasAddedExtraModelFiles) {
NSArray<URL> additionalModelURLs = additionalModelURLs();
for (URL url : additionalModelURLs) {
modelFiles.add(url.getFile());
}
_hasAddedExtraModelFiles = true;
}
return modelFiles;
}

private boolean _hasAddedExtraModelFiles=false;

/**
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 @@ -376,33 +376,6 @@ public void configureAdaptorContext(NSNotification n) {
ERXExtensions.configureAdaptorContext();
}

/**
* This method is called every time a session times
* out. It allows us to release references to all the
* editing contexts that were created when that particular
* session was active.
* Not used in WO 5.2+
* @param n notification that contains the session ID.
* @deprecated not needed anymore in WO 5.4
*/
@Deprecated
public void sessionDidTimeOut(NSNotification n) {
String sessionID=(String)n.object();
ERXExtensions.sessionDidTimeOut(sessionID);
}

/**
* This is needed for WO pre-5.2 when ec's were not
* retained by their eos. Not called in 5.2+ systems.
* @param n notification posted when an ec is created
* @deprecated not needed anymore in WO 5.4
*/
@Deprecated
public void editingContextDidCreate(NSNotification n) {
EOEditingContext ec = (EOEditingContext)n.object();
ERXExtensions.retainEditingContextForCurrentSession(ec);
}

/**
* This method is called for the following notification
* {@link EOSharedEditingContext#DefaultSharedEditingContextWasInitializedNotification}
Expand Down Expand Up @@ -517,73 +490,6 @@ public static void setAdaptorLogging(boolean onOff) {
adaptorEnabled = targetState;
}

/**
* Retaining the editing contexts explicitly until the session that was active
* when they were created goes away
* this hopefully will go some way towards avoiding the 'attempted to send'
* message to EO whose EditingContext is gone. Only used in pre-5.2 systems.
*/
@Deprecated
private static NSMutableDictionary _editingContextsPerSession;

/**
* This method is called when a session times out.
* Calling this method will release references to
* all editing contexts that were created when this
* session was active. This method is only called in
* pre-WO 5.2 versions of WebObjects.
* @param sessionID of the session that timed out
* @deprecated not needed anymore in WO 5.4
*/
@Deprecated
public static void sessionDidTimeOut(String sessionID) {
if (sessionID != null) {
if (_editingContextsPerSession != null) {
if (_log.isDebugEnabled()) {
NSArray a=(NSArray)_editingContextsPerSession.objectForKey(sessionID);
_log.debug("Session "+sessionID+" is timing out ");
_log.debug("Found "+ ((a == null) ? 0 : a.count()) + " editing context(s)");
}
NSArray ecs = (NSArray)_editingContextsPerSession.removeObjectForKey(sessionID);
// Just helping things along.
if (ecs != null && ecs.count() > 0) {
for (Enumeration ecEnumerator = ecs.objectEnumerator(); ecEnumerator.hasMoreElements();) {
((EOEditingContext)ecEnumerator.nextElement()).dispose();
}
}
}
}
}

/**
* Retains an editing context for the current session. This is only needed or
* used for versions of WO pre-5.2. If you use ERXEC to create your editing
* contexts then you never need to call this method yourself.
* @param ec to be retained.
* @deprecated not needed anymore in WO 5.4
*/
@Deprecated
public static void retainEditingContextForCurrentSession(EOEditingContext ec) {
WOSession s= ERXSession.session();
if (s != null) {
if (_editingContextsPerSession == null) {
_editingContextsPerSession = new NSMutableDictionary();
}
NSMutableArray a = (NSMutableArray)_editingContextsPerSession.objectForKey(s.sessionID());
if (a == null) {
a = new NSMutableArray();
_editingContextsPerSession.setObjectForKey(a, s.sessionID());
if (_log.isDebugEnabled())
_log.debug("Creating array for "+s.sessionID());
}
a.addObject(ec);
if (_log.isDebugEnabled())
_log.debug("Added new ec to array for "+s.sessionID());
} else if (_log.isDebugEnabled()) {
_log.debug("Editing Context created with null session.");
}
}

/**
* Removes all of the HTML tags from a given string.
* Note: this is a very simplistic implementation
Expand Down
Loading

0 comments on commit be6a524

Please sign in to comment.