From: Eyal Alalouf Date: Sun, 14 Jan 2007 17:10:38 +0000 (-0000) Subject: Add portal support X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=a7135f35cdda066b6ba9808eadf747a8a887012d;p=mono.git Add portal support svn path=/trunk/mcs/; revision=70988 --- diff --git a/mcs/class/System.Web/ChangeLog b/mcs/class/System.Web/ChangeLog index 3aeb73656f6..74ba723e074 100644 --- a/mcs/class/System.Web/ChangeLog +++ b/mcs/class/System.Web/ChangeLog @@ -1,3 +1,8 @@ +2007-01-14 Eyal Alaluf + + * System.Web20.vmwcsproj: added .jvm files for Control.cs, Page.cs, + HttpRequest.cs & HttpContext.cs + 2007-01-07 Vladimir Krasnov * System.Web20.vmwcsproj: added ProfileParameter.cs diff --git a/mcs/class/System.Web/System.Web.J2EE/J2EEUtils.cs b/mcs/class/System.Web/System.Web.J2EE/J2EEUtils.cs index deb055fe31c..aac898cb5b2 100644 --- a/mcs/class/System.Web/System.Web.J2EE/J2EEUtils.cs +++ b/mcs/class/System.Web/System.Web.J2EE/J2EEUtils.cs @@ -31,12 +31,8 @@ using vmw.common; namespace System.Web.J2EE { - internal sealed class J2EEUtils + internal static class J2EEUtils { - public J2EEUtils() - { - } - public static int RunProc(string[] cmd) { java.lang.Runtime rt = java.lang.Runtime.getRuntime(); diff --git a/mcs/class/System.Web/System.Web.SessionState/HttpSessionState.jvm.cs b/mcs/class/System.Web/System.Web.SessionState/HttpSessionState.jvm.cs deleted file mode 100644 index b5d91c26859..00000000000 --- a/mcs/class/System.Web/System.Web.SessionState/HttpSessionState.jvm.cs +++ /dev/null @@ -1,366 +0,0 @@ -// -// System.Web.SessionState.HttpSessionState.jvm.cs -// -// Authors: -// Ilya Kharmatsky (ilyak@mainsoft.com) -// Alon Gazit -// Pavel Sandler -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Globalization; -using System.Text; -using System.Threading; -using System.Web; -using System.Web.J2EE; -using System.Web.Hosting; - -namespace System.Web.SessionState -{ -public sealed class HttpSessionState : ICollection, IEnumerable, java.io.Externalizable -{ - private string _id; - private SessionDictionary _dict; - private HttpStaticObjectsCollection _staticObjects; - private int _timeout; - private bool _newSession; - private bool _isCookieless; - private SessionStateMode _mode; - private bool _isReadonly; - internal bool _abandoned; - - private bool _needSessionPersistence = false; - - internal HttpSessionState (string id, - SessionDictionary dict, - HttpStaticObjectsCollection staticObjects, - int timeout, - bool newSession, - bool isCookieless, - SessionStateMode mode, - bool isReadonly) - { - _id = id; - _dict = dict; - _staticObjects = staticObjects.Clone (); - _timeout = timeout; - _newSession = newSession; - _isCookieless = isCookieless; - _mode = mode; - _isReadonly = isReadonly; - - _needSessionPersistence = false; - javax.servlet.ServletConfig config = (javax.servlet.ServletConfig)AppDomain.CurrentDomain.GetData(J2EEConsts.SERVLET_CONFIG); - string sessionPersistance = config.getInitParameter(J2EEConsts.Enable_Session_Persistency); - if (sessionPersistance!= null) - { - try - { - _needSessionPersistence = Boolean.Parse(sessionPersistance); - } - catch (Exception) - { - Console.WriteLine("EnableSessionPersistency init param's value is invalid. the value is " + sessionPersistance); - } - } - } - - public HttpSessionState () - { - _id = null; - _dict = new SessionDictionary(); - _staticObjects = new HttpStaticObjectsCollection(); - _timeout = 0; - _newSession = false; - _isCookieless = false; - _mode = SessionStateMode.Off; - _isReadonly = false; - } - - public void writeExternal(java.io.ObjectOutput output) - { - lock (this) - { - output.writeBoolean(_needSessionPersistence); - if (!_needSessionPersistence) - //indicates that there is nothing to serialize for this object - return; - - System.Web.J2EE.ObjectOutputStream ms = new System.Web.J2EE.ObjectOutputStream(output); - System.IO.BinaryWriter bw = new System.IO.BinaryWriter(ms); - bw.Write(_id); - _dict.Serialize(bw); - _staticObjects.Serialize(bw); - bw.Write(_timeout); - bw.Write(_newSession); - bw.Write(_isCookieless); - if (_mode == SessionStateMode.Off) - bw.Write(0); - else if (_mode == SessionStateMode.InProc) - bw.Write(1); - else if (_mode == SessionStateMode.StateServer) - bw.Write(2); - else - bw.Write(3); - bw.Write(_isReadonly); - } - } - - public void readExternal(java.io.ObjectInput input) - { - lock(this) - { - _needSessionPersistence = input.readBoolean(); - if(!_needSessionPersistence) //noting has been written - return; - - System.Web.J2EE.ObjectInputStream ms = new System.Web.J2EE.ObjectInputStream( input ); - System.IO.BinaryReader br = new System.IO.BinaryReader(ms); - _id = br.ReadString(); - _dict = SessionDictionary.Deserialize(br); - _staticObjects = HttpStaticObjectsCollection.Deserialize(br); - _timeout = br.ReadInt32(); - _newSession = br.ReadBoolean(); - _isCookieless = br.ReadBoolean(); - int mode = br.ReadInt32(); - if (mode == 0) - _mode = SessionStateMode.Off; - else if (mode == 1) - _mode = SessionStateMode.InProc; - else if (mode == 2) - _mode = SessionStateMode.StateServer; - else - _mode = SessionStateMode.SQLServer; - _isReadonly = br.ReadBoolean(); - } - } - - internal HttpSessionState Clone () - { - return new HttpSessionState (_id, _dict.Clone (), _staticObjects, _timeout, _newSession, - _isCookieless, _mode, _isReadonly); - - } - - public int CodePage { - get { - HttpContext current = HttpContext.Current; - if (current == null) - return Encoding.Default.CodePage; - - return current.Response.ContentEncoding.CodePage; - } - - set { - HttpContext current = HttpContext.Current; - if (current != null) - current.Response.ContentEncoding = Encoding.GetEncoding (value); - } - } - - public HttpSessionState Contents { - get { return this; } - } - - public int Count { - get { return _dict.Count; } - } - - internal bool IsAbandoned { - get { return _abandoned; } - } - - public bool IsCookieless { - get { - ServletWorkerRequest worker = (ServletWorkerRequest)HttpContext.Current.Request.WorkerRequest; - return worker.ServletRequest.isRequestedSessionIdFromURL(); - } - } - - public bool IsNewSession { - get { return _newSession; } - } - - public bool IsReadOnly { - get { return _isReadonly; } - } - - public bool IsSynchronized { - get { return false; } - } - - public object this [string key] { - get { return _dict [key]; } - set { - _dict [key] = value; - - _newSession = false; - SetJavaSessionAttribute(); - } - } - - public object this [int index] { - get { return _dict [index]; } - set { - _dict [index] = value; - - _newSession = false; - SetJavaSessionAttribute(); - } - } - - public NameObjectCollectionBase.KeysCollection Keys { - get { return _dict.Keys; } - } - - public int LCID { - get { return Thread.CurrentThread.CurrentCulture.LCID; } - set { Thread.CurrentThread.CurrentCulture = new CultureInfo(value); } - } - - public SessionStateMode Mode { - get { return _mode; } - } - - public string SessionID { - get { return _id; } - } - - public HttpStaticObjectsCollection StaticObjects { - get { return _staticObjects; } - } - - public object SyncRoot { - get { return this; } - } - - public int Timeout { - get { - ServletWorkerRequest worker = (ServletWorkerRequest)HttpContext.Current.Request.WorkerRequest; - javax.servlet.http.HttpSession javaSession = worker.ServletRequest.getSession(false); - if (javaSession != null) - return javaSession.getMaxInactiveInterval()/60; - else - throw new NotSupportedException(); - } - set { - if (value < 1) - throw new ArgumentException ("The argument to SetTimeout must be greater than 0."); - ServletWorkerRequest worker = (ServletWorkerRequest)HttpContext.Current.Request.WorkerRequest; - javax.servlet.http.HttpSession javaSession = worker.ServletRequest.getSession(false); - if (javaSession != null) - javaSession.setMaxInactiveInterval(value*60); - else - throw new NotSupportedException(); - } - } - - internal SessionDictionary SessionDictionary { - get { return _dict; } - } - - internal void SetNewSession (bool value) - { - _newSession = value; - } - - public void Abandon () - { - _abandoned = true; - - SessionDictionary.Clear(); - ServletWorkerRequest worker = (ServletWorkerRequest)HttpContext.Current.Request.WorkerRequest; -// worker.Servlet.getServletContext().removeAttribute("GH_SESSION_STATE"); - javax.servlet.http.HttpSession javaSession = worker.ServletRequest.getSession(false); - - if (javaSession != null) - { - javaSession.setAttribute("GH_SESSION_STATE",this); - javaSession.invalidate(); - } - } - - public void Add (string name, object value) - { - _dict [name] = value; - - _newSession = false; - SetJavaSessionAttribute(); - } - - public void Clear () - { - if (_dict != null) - _dict.Clear (); - - SetJavaSessionAttribute(); - } - - public void CopyTo (Array array, int index) - { - NameObjectCollectionBase.KeysCollection all = Keys; - for (int i = 0; i < all.Count; i++) - array.SetValue (all.Get(i), i + index); - } - - public IEnumerator GetEnumerator () - { - return _dict.GetEnumerator (); - } - - public void Remove (string name) - { - _dict.Remove (name); - - SetJavaSessionAttribute(); - } - - public void RemoveAll () - { - _dict.Clear (); - - SetJavaSessionAttribute(); - } - - public void RemoveAt (int index) - { - _dict.RemoveAt (index); - - SetJavaSessionAttribute(); - } - - public void SetJavaSessionAttribute () - { - ServletWorkerRequest worker = (ServletWorkerRequest)HttpContext.Current.Request.WorkerRequest; - javax.servlet.http.HttpSession javaSession = worker.ServletRequest.getSession(false); - if (javaSession != null) - javaSession.setAttribute("GH_SESSION_STATE",this); - } -} -} - diff --git a/mcs/class/System.Web/System.Web.SessionState/SessionInProcHandler.jvm.cs b/mcs/class/System.Web/System.Web.SessionState/SessionInProcHandler.jvm.cs deleted file mode 100644 index 1fedb456edc..00000000000 --- a/mcs/class/System.Web/System.Web.SessionState/SessionInProcHandler.jvm.cs +++ /dev/null @@ -1,107 +0,0 @@ -// -// System.Web.SessionState.SesionInProchandler.jvm.cs -// -// Authors: -// Ilya Kharmatsky (ilyak@mainsoft.com) -// Alon Gazit -// Pavel Sandler -// -// (C) 2005 Mainsoft Corporation (http://www.mainsoft.com) -// - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -#if !NET_2_0 -using System; -using System.IO; -using System.Collections; -using System.Web; -using System.Web.Hosting; -using System.Web.Configuration; - -namespace System.Web.SessionState -{ - - class SessionInProcHandler : ISessionHandler - { - -#if NET_2_0 - SessionStateSection config; -#else - SessionConfig config; -#endif - - public void Dispose () { } - - public void Init (SessionStateModule module, HttpApplication context, -#if NET_2_0 - SessionStateSection config -#else - SessionConfig config -#endif -) - { - this.config = config; - } - - public void UpdateHandler (HttpContext context, SessionStateModule module) { } - - public HttpSessionState UpdateContext (HttpContext context, SessionStateModule module, - bool required, bool read_only, ref bool isNew) - { - - if (!required) - return null; - - ServletWorkerRequest worker = (ServletWorkerRequest)context.Request.WorkerRequest; - javax.servlet.http.HttpSession javaSession = worker.ServletRequest.getSession(false); - HttpSessionState state; - if (javaSession != null) - { - state = (HttpSessionState) javaSession.getAttribute("GH_SESSION_STATE"); - return state; - } - - // We create a new session. - javaSession = worker.ServletRequest.getSession(true); - string sessionID = javaSession.getId(); - state = new HttpSessionState (sessionID, // unique identifier - new SessionDictionary(), // dictionary - HttpApplicationFactory.ApplicationState.SessionObjects, -#if NET_2_0 - (int)config.Timeout.TotalMinutes, // XXX is this right? we lose some precision here, but since the timeout is in minutes *anyway*... -#else - config.Timeout, //lifetime before death. -#endif - true, //new session - false, // is cookieless - SessionStateMode.J2ee, - read_only); //readonly - - javaSession.setAttribute("GH_SESSION_STATE", state); - - isNew = true; - return state; - } - } -} - -#endif diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog index ef5c741bae8..93a854a616d 100644 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog @@ -1,4 +1,8 @@ -2007-01-07 Eyal Alaluf +2007-01-14 Eyal Alaluf + + * HtmlForm.cs, HtmlAnchor.cs: Added H2EE Portal support for TARGET_J2EE. + +2007-01-14 Eyal Alaluf * HtmlInputImage.cs: to handle correctly relative URLs to the image. diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlAnchor.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlAnchor.cs index 8b9116d2fc8..304de1ed9eb 100644 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlAnchor.cs +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlAnchor.cs @@ -165,8 +165,11 @@ namespace System.Web.UI.HtmlControls { protected override void RenderAttributes (HtmlTextWriter writer) { - // we don't want to render the "user" URL, so we either render: + string target = Attributes ["target"]; + if ((target == null) || (target.Length == 0)) + Attributes.Remove("target"); + // we don't want to render the "user" URL, so we either render: EventHandler serverClick = (EventHandler) Events [serverClickEvent]; if (serverClick != null) { #if NET_2_0 @@ -181,13 +184,14 @@ namespace System.Web.UI.HtmlControls { } else { string hr = HRef; if (hr != "") +#if TARGET_J2EE + // For J2EE portlets we need to genreate a render URL. + HRef = ResolveUrl (hr, String.Compare(target, "_blank", true) != 0); +#else HRef = ResolveUrl (hr); +#endif } - string target = Attributes ["target"]; - if ((target == null) || (target.Length == 0)) - Attributes.Remove("target"); - base.RenderAttributes (writer); // but we never set back the href attribute after the rendering diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs index 5493e0714c4..e5661da62ed 100644 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs @@ -250,6 +250,11 @@ namespace System.Web.UI.HtmlControls } action += Page.Request.QueryStringRaw; +#if TARGET_J2EE + vmw.@internal.j2ee.IPortletRenderResponse resp = GetRenderResponse(); + if (resp != null) + action = resp.createActionURL(action); +#endif w.WriteAttribute ("name", Name); diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Button.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Button.cs index 3b4311379e3..1b47d3332b5 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/Button.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/Button.cs @@ -213,6 +213,11 @@ namespace System.Web.UI.WebControls { { PostBackOptions options = new PostBackOptions (this); options.ActionUrl = (PostBackUrl.Length > 0 ? Page.ResolveClientUrl (PostBackUrl) : null); +#if TARGET_J2EE + vmw.@internal.j2ee.IPortletRenderResponse resp = GetRenderResponse(); + if (resp != null && options.ActionUrl != null) + options.ActionUrl = resp.createActionURL(options.ActionUrl); +#endif options.ValidationGroup = null; options.Argument = ""; options.RequiresJavaScriptProtocol = false; diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog index 403c55cd180..059206a48fc 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog @@ -1,3 +1,7 @@ +2007-01-14 Eyal Alaluf + * Button.cs, HyperLink.cs, DataGrid.cs, ImageButton.cs, LinkButton.cs, + PagedDataSource.cs: Added J2EE Portal support for TARGET_J2EE. + 2007-01-14 Ilya Kharmatsky * BaseCompareValidator * CompareValidator diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs index dd5768e3a6a..db501d5a69d 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs @@ -865,29 +865,6 @@ namespace System.Web.UI.WebControls { class NCollection : ICollection { int n; -#if TARGET_JVM - class SequenceEnumerator : IEnumerator { - readonly int _max; - object _current; - public SequenceEnumerator(int max) { - _max = max; - Reset(); - } - - public bool MoveNext() { - _current = (int)_current + 1; - return (int)_current >= 0 && (int)_current < _max; - } - - public void Reset() { - _current = -1; - } - - public object Current { - get { return _current; } - } - } -#endif public NCollection (int n) { @@ -896,12 +873,8 @@ namespace System.Web.UI.WebControls { public IEnumerator GetEnumerator () { -#if TARGET_JVM - return new SequenceEnumerator(n); -#else for (int i = 0; i < n; i++) yield return i; -#endif } public int Count { diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs b/mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs index 2031bf66270..750a1fc026d 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/HyperLink.cs @@ -59,12 +59,16 @@ namespace System.Web.UI.WebControls { if (!Enabled) return; // add attributes - only if they're not empty + string t = Target; string s = NavigateUrl; if (s.Length > 0) +#if TARGET_J2EE + w.AddAttribute (HtmlTextWriterAttribute.Href, ResolveClientUrl (s, String.Compare (t, "_blank", true) != 0)); +#else w.AddAttribute (HtmlTextWriterAttribute.Href, ResolveClientUrl (s)); - s = Target; - if (s.Length > 0) - w.AddAttribute (HtmlTextWriterAttribute.Target, s); +#endif + if (t.Length > 0) + w.AddAttribute (HtmlTextWriterAttribute.Target, t); } protected override void AddParsedSubObject (object obj) diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs b/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs index 11c96c2b326..79e2d4bf1b0 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/ImageButton.cs @@ -239,6 +239,11 @@ namespace System.Web.UI.WebControls { { PostBackOptions options = new PostBackOptions (this); options.ActionUrl = (PostBackUrl.Length > 0 ? Page.ResolveClientUrl (PostBackUrl) : null); +#if TARGET_J2EE + vmw.@internal.j2ee.IPortletRenderResponse resp = GetRenderResponse(); + if (resp != null && options.ActionUrl != null) + options.ActionUrl = resp.createActionURL(options.ActionUrl); +#endif options.ValidationGroup = null; options.Argument = ""; options.ClientSubmit = false; diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs b/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs index da58ecc38be..fdee9dc79ce 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/LinkButton.cs @@ -143,6 +143,11 @@ namespace System.Web.UI.WebControls { { PostBackOptions options = new PostBackOptions (this); options.ActionUrl = (PostBackUrl.Length > 0 ? Page.ResolveClientUrl (PostBackUrl) : null); +#if TARGET_J2EE + vmw.@internal.j2ee.IPortletRenderResponse resp = GetRenderResponse(); + if (resp != null && options.ActionUrl != null) + options.ActionUrl = resp.createActionURL(options.ActionUrl); +#endif options.ValidationGroup = null; options.Argument = ""; options.ClientSubmit = true; diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/PagedDataSource.cs b/mcs/class/System.Web/System.Web.UI.WebControls/PagedDataSource.cs index d3cd36a46c7..71f73d24614 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/PagedDataSource.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/PagedDataSource.cs @@ -241,77 +241,6 @@ namespace System.Web.UI.WebControls { return String.Empty; // as documented } -#if TARGET_JVM - internal class ListEnum : IEnumerator - { - int start; - int end; - int ind; - IList list; - - internal ListEnum(IList list, int start, int end) - { - this.list = list; - this.start = start; - this.end = end; - this.ind = start - 1; - } - - public bool MoveNext() - { - ind++; - return (ind < end); - } - - public void Reset() { ind = start - 1; } - public object Current { get { return list[ind]; }} - } - - private IEnumerator GetListEnum (IList list, int start, int end) - { - if (!allow_paging) - end = list.Count; - return new ListEnum(list, start, end); - } - - internal class EnumeratorEnum : IEnumerator - { - int start; - int end; - int ind; - IEnumerator en; - PagedDataSource parent; - - internal EnumeratorEnum(PagedDataSource parent, IEnumerator en, int start, int end) - { - this.parent = parent; - this.en = en; - this.start = start; - this.end = end; - this.ind = start - 1; - for (int i = 0; i < start; i++) - en.MoveNext (); - } - - public bool MoveNext() - { - ind++; - return (!parent.allow_paging || ind < end) && en.MoveNext (); - } - - public void Reset() - { - throw new NotSupportedException(); - } - - public object Current { get { return en.Current; }} - } - - private IEnumerator GetEnumeratorEnum (IEnumerator e, int start, int end) - { - return new EnumeratorEnum(this, e, start, end); - } -#else private IEnumerator GetListEnum (IList list, int start, int end) { if (!AllowPaging) @@ -330,7 +259,6 @@ namespace System.Web.UI.WebControls { for (int i = start; (!allow_paging || i < end) && e.MoveNext (); i++) yield return e.Current; } -#endif } } diff --git a/mcs/class/System.Web/System.Web.UI/ChangeLog b/mcs/class/System.Web/System.Web.UI/ChangeLog index 444c8d05c37..d2f7cbb9af4 100644 --- a/mcs/class/System.Web/System.Web.UI/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI/ChangeLog @@ -1,3 +1,9 @@ +2007-01-14 Eya; Alaluf + + * Control.jvm.cs, Page.jvm.cs: Added TARGET_J2EE specific files. + * Page.cs, ClientScriptManager.cs, Control.cs: Added J2EE portal + support for TARGET_J2EE. + 2007-01-12 Miguel de Icaza * Control.cs: Remove comment, it provides no information about diff --git a/mcs/class/System.Web/System.Web.UI/ClientScriptManager.cs b/mcs/class/System.Web/System.Web.UI/ClientScriptManager.cs index af12cc894e0..b5335db651f 100644 --- a/mcs/class/System.Web/System.Web.UI/ClientScriptManager.cs +++ b/mcs/class/System.Web/System.Web.UI/ClientScriptManager.cs @@ -99,7 +99,7 @@ namespace System.Web.UI throw new ArgumentNullException ("control"); page.RequiresPostBackScript (); - return String.Format ("__doPostBack('{0}','{1}')", control.UniqueID, argument); + return String.Format ("{0}('{1}','{2}')", page.PostBackFunctionName, control.UniqueID, argument); } #if NET_2_0 diff --git a/mcs/class/System.Web/System.Web.UI/Control.cs b/mcs/class/System.Web/System.Web.UI/Control.cs index 7f476664a28..2c36b5967c9 100644 --- a/mcs/class/System.Web/System.Web.UI/Control.cs +++ b/mcs/class/System.Web/System.Web.UI/Control.cs @@ -66,7 +66,7 @@ namespace System.Web.UI [DesignerSerializer ("Microsoft.VSDesigner.WebForms.ControlCodeDomSerializer, " + Consts.AssemblyMicrosoft_VSDesigner, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)] #endif - public class Control : IComponent, IDisposable, IParserAccessor, IDataBindingsAccessor + public partial class Control : IComponent, IDisposable, IParserAccessor, IDataBindingsAccessor #if NET_2_0 , IUrlResolutionService, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor #endif @@ -532,6 +532,7 @@ namespace System.Web.UI defaultNumberID = 0; } +#if !TARGET_J2EE string GetDefaultName () { string defaultName; @@ -542,6 +543,7 @@ namespace System.Web.UI } return defaultName; } +#endif void NullifyUniqueID () { @@ -1149,6 +1151,11 @@ namespace System.Web.UI string ResolveClientUrl (string relativeUrl) { string absoluteUrl = ResolveUrl (relativeUrl); +#if TARGET_J2EE + // There are no relative paths when rendering a J2EE portlet + if (IsPortletRender) + return absoluteUrl; +#endif if (Context != null && Context.Request != null) { string baseUrl = Context.Request.BaseVirtualDir; if (absoluteUrl.StartsWith (baseUrl + "/")) diff --git a/mcs/class/System.Web/System.Web.UI/Control.jvm.cs b/mcs/class/System.Web/System.Web.UI/Control.jvm.cs new file mode 100644 index 00000000000..fa106e41f6d --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI/Control.jvm.cs @@ -0,0 +1,99 @@ +// +// System.Web.UI.ControlS.jvm.cs +// +// Authors: +// Eyal Alaluf (eyala@mainsoft.com) +// +// (C) 2006 Mainsoft Co. (http://www.mainsoft.com) +// + +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using vmw.@internal.j2ee; +using System.Web.Hosting; + +namespace System.Web.UI +{ + public partial class Control + { + bool _emptyPortletNamespace = false; + string _PortletNamespace = null; + + internal bool IsPortletRender + { + get { + return GetRenderResponse() != null; + } + } + + // For J2EE Portal we need to use the portlet namespace when we generate control IDs. + string GetDefaultName () + { + string defaultName; + if (defaultNumberID > 99) { + defaultName = "_ctl" + defaultNumberID++; + } else { + defaultName = defaultNameArray [defaultNumberID++]; + } + + if (this != _page || _emptyPortletNamespace) + return defaultName; + + if (_PortletNamespace == null) { + IPortletResponse portletResponse = GetRenderResponse (); + if (portletResponse != null) + _PortletNamespace = portletResponse.getNamespace (); + _emptyPortletNamespace = _PortletNamespace == null; + } + + return _PortletNamespace + defaultName; + } + + // Add a variant for specifying use of portlet resolveRenderUrl + internal string ResolveUrl (string relativeUrl, bool usePortletRenderResolve) + { + relativeUrl = ResolveUrl (relativeUrl); + if (usePortletRenderResolve) { + IPortletRenderResponse resp = GetRenderResponse (); + if (resp != null) + relativeUrl = resp.createRenderURL (relativeUrl); + } + return relativeUrl; + } + + internal string ResolveClientUrl (string relativeUrl, bool usePortletRenderResolve) + { + relativeUrl = ResolveClientUrl (relativeUrl); + if (usePortletRenderResolve) { + IPortletRenderResponse resp = GetRenderResponse (); + if (resp != null) + relativeUrl = resp.createRenderURL (relativeUrl); + } + return relativeUrl; + } + + internal IPortletRenderResponse GetRenderResponse () + { + return Context.ServletResponse as IPortletRenderResponse; + } + } +} diff --git a/mcs/class/System.Web/System.Web.UI/Page.cs b/mcs/class/System.Web/System.Web.UI/Page.cs index a967ec1e4f8..d56367b4770 100644 --- a/mcs/class/System.Web/System.Web.UI/Page.cs +++ b/mcs/class/System.Web/System.Web.UI/Page.cs @@ -68,7 +68,7 @@ namespace System.Web.UI #else [Designer ("Microsoft.VSDesigner.WebForms.WebFormDesigner, " + Consts.AssemblyMicrosoft_VSDesigner, typeof (IRootDesigner))] #endif -public class Page : TemplateControl, IHttpHandler +public partial class Page : TemplateControl, IHttpHandler { #if NET_2_0 private PageLifeCycle _lifeCycle = PageLifeCycle.Unknown; @@ -439,6 +439,14 @@ public class Page : TemplateControl, IHttpHandler } #endif +#if !TARGET_J2EE + internal string PostBackFunctionName { + get { + return "__doPostBack"; + } + } +#endif + [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)] [Browsable (false)] public HttpRequest Request @@ -754,6 +762,10 @@ public class Page : TemplateControl, IHttpHandler coll = req.QueryString; } +#if TARGET_J2EE + coll = LoadViewStateForPortlet((WebROCollection)coll); +#endif + if (coll != null && coll ["__VIEWSTATE"] == null && coll ["__EVENTTARGET"] == null) return null; @@ -955,7 +967,7 @@ public class Page : TemplateControl, IHttpHandler writer.WriteLine ("\tvar theForm;\n\tif (document.getElementById) {{ theForm = document.getElementById ('{0}'); }}", formUniqueID); writer.WriteLine ("\telse {{ theForm = document.{0}; }}", formUniqueID); - writer.WriteLine ("\tfunction __doPostBack(eventTarget, eventArgument) {"); + writer.WriteLine ("\tfunction " + PostBackFunctionName + "(eventTarget, eventArgument) {"); writer.WriteLine ("\t\tif(document.ValidatorOnSubmit && !ValidatorOnSubmit()) return;"); writer.WriteLine ("\t\ttheForm.{0}.value = eventTarget;", postEventSourceID); writer.WriteLine ("\t\ttheForm.{0}.value = eventArgument;", postEventArgumentID); @@ -989,7 +1001,7 @@ public class Page : TemplateControl, IHttpHandler return new ObjectStateFormatter (this); } - internal object GetSavedViewState () + internal string GetSavedViewState () { return _savedViewState; } @@ -1257,6 +1269,14 @@ public class Page : TemplateControl, IHttpHandler #if NET_2_0 _lifeCycle = PageLifeCycle.SaveStateComplete; OnSaveStateComplete (EventArgs.Empty); +#endif + +#if TARGET_J2EE + if (SaveViewStateForNextPortletRender()) + return; +#endif + +#if NET_2_0 _lifeCycle = PageLifeCycle.Render; #endif diff --git a/mcs/class/System.Web/System.Web.UI/Page.jvm.cs b/mcs/class/System.Web/System.Web.UI/Page.jvm.cs new file mode 100644 index 00000000000..e9ecfb8580a --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI/Page.jvm.cs @@ -0,0 +1,83 @@ +// +// System.Web.UI.Page.jvm.cs +// +// Authors: +// Eyal Alaluf (eyala@mainsoft.com) +// +// (C) 2006 Mainsoft Co. (http://www.mainsoft.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using vmw.@internal.j2ee; +using javax.servlet.http; +using System.Collections.Specialized; +using System.Web.Hosting; + +namespace System.Web.UI +{ + public partial class Page + { + internal string PostBackFunctionName { + get { +#if LATER // Enable when we fix the jscripts not to reference __doPostBack. + IPortletRenderResponse resp = GetRenderResponse(); + if (resp != null) + return "__doPostBack_" + resp.getNamespace(); +#endif + return "__doPostBack"; + } + } + + // For J2EE portlets we load the view state from the render parameters + WebROCollection LoadViewStateForPortlet(WebROCollection coll) + { + IPortletRenderRequest renderRequest = Context.ServletRequest as IPortletRenderRequest; + if (renderRequest != null && (coll == null || coll ["__VIEWSTATE"] == null)) { + string mode = renderRequest.getPortletMode(); + string viewstate = Context.ServletRequest.getParameter("vmw.viewstate." + mode); + if (viewstate != null) { + if (coll == null) + coll = new WebROCollection(); + else + coll.Unprotect(); + coll["__VIEWSTATE"] = viewstate; + coll.Protect(); + } + } + return coll; + } + + internal bool SaveViewStateForNextPortletRender() + { + IPortletActionResponse resp = Context.ServletResponse as IPortletActionResponse; + IPortletActionRequest req = Context.ServletRequest as IPortletActionRequest; + if (req == null) + return false; + + if (IsPostBack && String.Compare (Request.HttpMethod, "POST", true) == 0 && !resp.isRedirected()) + resp.setRenderParameter("vmw.viewstate." + req.getPortletMode(), GetSavedViewState()); + + // Stop processing only if we are handling processAction. If we + // are handling a postback from render then fall through. + return req.processActionOnly() || resp.isRedirected(); + } + } +} diff --git a/mcs/class/System.Web/System.Web/ChangeLog b/mcs/class/System.Web/System.Web/ChangeLog index 21f8d9365ec..a7e60cd68a3 100644 --- a/mcs/class/System.Web/System.Web/ChangeLog +++ b/mcs/class/System.Web/System.Web/ChangeLog @@ -1,3 +1,9 @@ +2007-01-14 Eyal Alaluf + + * HttpRequest.jvm.cs, HttpContext.jvm.cs: Added TARGET_J2EE specific files. + * HttpContext.cs, HttpResponse.cs, HttpRequest.cs, HttpCookie.cs: + Add J2EE Portal support for TARGET_J2EE. + 2007-01-04 Vladimir Krasnov * HttpRequest.cs: fixed IsLocal, should check all ip addresses of host diff --git a/mcs/class/System.Web/System.Web/HttpContext.cs b/mcs/class/System.Web/System.Web/HttpContext.cs index 2cd58be74ab..bc9341995c6 100644 --- a/mcs/class/System.Web/System.Web/HttpContext.cs +++ b/mcs/class/System.Web/System.Web/HttpContext.cs @@ -55,7 +55,7 @@ namespace System.Web { // CAS - no InheritanceDemand here as the class is sealed [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] - public sealed class HttpContext : IServiceProvider { + public sealed partial class HttpContext : IServiceProvider { internal HttpWorkerRequest WorkerRequest; HttpApplication app_instance; HttpRequest request; @@ -77,10 +77,7 @@ namespace System.Web { ProfileBase profile = null; LinkedList handlers; #endif -#if TARGET_JVM // No remoting support (CallContext) yet in Grasshopper - static LocalDataStoreSlot _ContextSlot = Thread.GetNamedDataSlot ("Context"); -#endif - + public HttpContext (HttpWorkerRequest wr) { WorkerRequest = wr; @@ -136,14 +133,7 @@ namespace System.Web { // The "Current" property is set just after we have constructed it with // the 'HttpContext (HttpWorkerRequest)' constructor. // -#if TARGET_JVM // No remoting support (CallContext) yet in Grasshopper - [MonoTODO("Context - Use System.Remoting.Messaging.CallContext instead of Thread storage")] - public static HttpContext Current - { - get { return (HttpContext) Thread.GetData (_ContextSlot); } - set { Thread.SetData (_ContextSlot, value); } - } -#else +#if !TARGET_JVM // No remoting CallContext support in Grasshopper public static HttpContext Current { get { return (HttpContext) CallContext.GetData ("c"); @@ -195,9 +185,7 @@ namespace System.Web { (Request.WorkerRequest.GetLocalAddress () != Request.UserHostAddress); } } -#if TARGET_JVM - public bool IsDebuggingEnabled { get { return false; } } -#else +#if !TARGET_JVM public bool IsDebuggingEnabled { get { #if NET_2_0 diff --git a/mcs/class/System.Web/System.Web/HttpContext.jvm.cs b/mcs/class/System.Web/System.Web/HttpContext.jvm.cs new file mode 100644 index 00000000000..d59f8349ed0 --- /dev/null +++ b/mcs/class/System.Web/System.Web/HttpContext.jvm.cs @@ -0,0 +1,67 @@ +// +// System.Web.HttpContext.cs +// +// Author: +// Eyal Alaluf (eyala@mainsoft.com) +// + +// +// Copyright (C) 2005 Mainsoft Co. (http://www.mainsoft.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System.Collections; +using System.Configuration; +using System.Threading; +using javax.servlet.http; + +namespace System.Web { + + public sealed partial class HttpContext { + static LocalDataStoreSlot _ContextSlot = Thread.GetNamedDataSlot ("Context"); + // No remoting support (CallContext) yet in Grasshopper + [MonoInternalNote("Context - Use System.Remoting.Messaging.CallContext instead of Thread storage")] + public static HttpContext Current + { + get { return (HttpContext) Thread.GetData (_ContextSlot); } + set { Thread.SetData (_ContextSlot, value); } + } + + public bool IsDebuggingEnabled { get { return false; } } + + internal object GetWorkerService(Type t) + { + return ((IServiceProvider) WorkerRequest).GetService(t); + } + + internal HttpServlet Servlet { + get { return (HttpServlet)GetWorkerService(typeof(HttpServlet)); } + } + + internal HttpServletRequest ServletRequest { + get { return (HttpServletRequest)GetWorkerService(typeof(HttpServletRequest)); } + } + + internal HttpServletResponse ServletResponse { + get { return (HttpServletResponse)GetWorkerService(typeof(HttpServletResponse)); } + } + } +} diff --git a/mcs/class/System.Web/System.Web/HttpCookie.cs b/mcs/class/System.Web/System.Web/HttpCookie.cs index f7e61e084fd..1010cf098ea 100644 --- a/mcs/class/System.Web/System.Web/HttpCookie.cs +++ b/mcs/class/System.Web/System.Web/HttpCookie.cs @@ -42,6 +42,10 @@ namespace System.Web { // CAS - no InheritanceDemand here as the class is sealed [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] +#if TARGET_J2EE + // Cookies must be serializable to be saved in the session for J2EE portal + [Serializable] +#endif public sealed class HttpCookie { string path = "/"; diff --git a/mcs/class/System.Web/System.Web/HttpRequest.cs b/mcs/class/System.Web/System.Web/HttpRequest.cs index 72e761f7e87..b4b7309bc3d 100644 --- a/mcs/class/System.Web/System.Web/HttpRequest.cs +++ b/mcs/class/System.Web/System.Web/HttpRequest.cs @@ -45,7 +45,7 @@ namespace System.Web { // CAS - no InheritanceDemand here as the class is sealed [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)] - public sealed class HttpRequest { + public sealed partial class HttpRequest { HttpWorkerRequest worker_request; HttpContext context; WebROCollection query_string_nvc; @@ -306,6 +306,10 @@ namespace System.Web { } } +#if TARGET_J2EE + // For J2EE portal support we emulate cookies using the session. + GetSessionCookiesForPortal (cookies); +#endif if (validate_cookies && !checked_cookies){ ValidateCookieCollection (cookies); checked_cookies = true; @@ -443,6 +447,7 @@ namespace System.Web { EndSubStream (input); } +#if !TARGET_J2EE // // Adds the key/value to the form, and sets the argumets to empty // @@ -491,7 +496,8 @@ namespace System.Web { EndSubStream (input); } - +#endif + bool IsContentType (string ct, bool starts_with) { if (starts_with) @@ -569,63 +575,7 @@ namespace System.Web { } } - -#if TARGET_JVM - const int INPUT_BUFFER_SIZE = 1024; - - void MakeInputStream () - { - if (worker_request == null) - throw new HttpException ("No HttpWorkerRequest"); - - // consider for perf: - // return ((ServletWorkerRequest)worker_request).InputStream(); - - // - // Use an unmanaged memory block as this might be a large - // upload - // - int content_length = ContentLength; - -#if NET_2_0 - HttpRuntimeSection config = (HttpRuntimeSection) WebConfigurationManager.GetSection ("system.web/httpRuntime"); -#else - HttpRuntimeConfig config = (HttpRuntimeConfig) HttpContext.GetAppConfig ("system.web/httpRuntime"); -#endif - if (content_length > (config.MaxRequestLength * 1024)) - throw new HttpException ("File exceeds httpRuntime limit"); - - byte[] content = new byte[content_length]; - if (content == null) - throw new HttpException (String.Format ("Not enough memory to allocate {0} bytes", content_length)); - - int total; - byte [] buffer; - buffer = worker_request.GetPreloadedEntityBody (); - if (buffer != null){ - total = buffer.Length; - if (content_length > 0) - total = Math.Min (content_length, total); - Array.Copy (buffer, content, total); - } else - total = 0; - - - buffer = new byte [INPUT_BUFFER_SIZE]; - while (total < content_length){ - int n; - n = worker_request.ReadEntityBody (buffer, Math.Min (content_length-total, INPUT_BUFFER_SIZE)); - if (n <= 0) - break; - Array.Copy (buffer, 0, content, total, n); - total += n; - } - if (total < content_length) - throw new HttpException (411, "The uploaded file is incomplete"); - - input_stream = new MemoryStream (content, 0, content.Length, false, true); - } -#else +#if !TARGET_JVM const int INPUT_BUFFER_SIZE = 32*1024; TempFileStream GetTempStream () @@ -804,6 +754,7 @@ namespace System.Web { throw new HttpException (411, "The request body is incomplete."); } #endif + internal void ReleaseResources () { Stream stream; diff --git a/mcs/class/System.Web/System.Web/HttpRequest.jvm.cs b/mcs/class/System.Web/System.Web/HttpRequest.jvm.cs new file mode 100644 index 00000000000..133f3da33e5 --- /dev/null +++ b/mcs/class/System.Web/System.Web/HttpRequest.jvm.cs @@ -0,0 +1,203 @@ +// +// System.Web.HttpRequest.jvm.cs +// +// +// Author: +// Eyal Alaluf +// + +// +// Copyright (C) 2006 Mainsoft, Co. (http://www.mainsoft.com) +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// +using System.Web.Hosting; +using javax.servlet.http; +using System.Web.Configuration; +using System.IO; +using System.Collections; +using vmw.@internal.j2ee; + +namespace System.Web +{ + public sealed partial class HttpRequest + { + private const string SessionLock = "vmw.session.lock"; + private const string SessionCookies = "vmw.session.cookies"; + + private static object GetJavaSessionLock (HttpSession javaSession) + { + lock (SessionLock) { + object sessionLock = javaSession.getAttribute (SessionLock); + if (sessionLock == null) { + sessionLock = String.Copy (SessionLock); + javaSession.setAttribute (SessionLock, sessionLock); + } + return sessionLock; + } + } + + void LoadWwwForm () + { + HttpServletRequest servletReq = context.ServletRequest; + + for (java.util.Enumeration e = servletReq.getParameterNames(); e.hasMoreElements() ;) { + string key = (string) e.nextElement(); + form.Add(key, servletReq.getParameter(key)); + } + } + + const int INPUT_BUFFER_SIZE = 1024; + + void MakeInputStream () + { + if (worker_request == null) + throw new HttpException ("No HttpWorkerRequest"); + + // consider for perf: + // return ((ServletWorkerRequest)worker_request).InputStream(); + + // + // Use an unmanaged memory block as this might be a large + // upload + // + int content_length = ContentLength; +#if NET_2_0 + HttpRuntimeSection config = (HttpRuntimeSection) WebConfigurationManager.GetSection ("system.web/httpRuntime"); +#else + HttpRuntimeConfig config = (HttpRuntimeConfig) HttpContext.GetAppConfig ("system.web/httpRuntime"); +#endif + if (content_length > (config.MaxRequestLength * 1024)) + throw new HttpException ("File exceeds httpRuntime limit"); + + byte[] content = new byte[content_length]; + if (content == null) + throw new HttpException (String.Format ("Not enough memory to allocate {0} bytes", content_length)); + + int total; + byte [] buffer; + buffer = worker_request.GetPreloadedEntityBody (); + if (buffer != null){ + total = buffer.Length; + if (content_length > 0) + total = Math.Min (content_length, total); + Array.Copy (buffer, content, total); + } + else + total = 0; + + buffer = new byte [INPUT_BUFFER_SIZE]; + while (total < content_length) { + int n; + n = worker_request.ReadEntityBody (buffer, Math.Min (content_length-total, INPUT_BUFFER_SIZE)); + if (n <= 0) + break; + Array.Copy (buffer, 0, content, total, n); + total += n; + } + if (total < content_length) + throw new HttpException (411, "The uploaded file is incomplete"); + + input_stream = new MemoryStream (content, 0, content.Length, false, true); + } + + internal void GetSessionCookiesForPortal (HttpCookieCollection cookies) + { + HttpSession javaSession = context.ServletRequest.getSession(false); + if (javaSession == null) + return; + + object sessionLock = GetJavaSessionLock (javaSession); + lock (sessionLock) { + Hashtable sessionCookies = (Hashtable) javaSession.getAttribute (SessionCookies); + if (sessionCookies == null) + return; + + ArrayList expiredCookies = null; + foreach (string key in sessionCookies.Keys) { + HttpCookie sessionCookie = (HttpCookie) sessionCookies [key]; + if (sessionCookie.Expires.Ticks != 0 && + sessionCookie.Expires.Ticks < DateTime.Now.Ticks) { + if (cookies [key] != null) + cookies.Remove (key); + else { + if (expiredCookies == null) + expiredCookies = new ArrayList(); + expiredCookies.Add (key); + } + } + else + cookies.Set (sessionCookie); + } + + if (expiredCookies != null) + foreach (object key in expiredCookies) + sessionCookies.Remove (key); + } + } + + internal void SetSessionCookiesForPortal (HttpCookieCollection cookies) + { + if (cookies == null || cookies.Count == 0) + return; + + HttpServletRequest servletReq = context.ServletRequest; + bool inPortletMode = servletReq is IPortletRequest; + bool shouldStoreCookiesCollection = false; + HttpSession javaSession = servletReq.getSession(false); + + if (javaSession == null && inPortletMode) + javaSession = servletReq.getSession(true); + + if (javaSession == null) + return; + + object sessionLock = GetJavaSessionLock (javaSession); + lock (sessionLock) { + Hashtable sessionCookies = (Hashtable)javaSession.getAttribute (SessionCookies); + if (sessionCookies == null) + if (inPortletMode) { + sessionCookies = new Hashtable (); + shouldStoreCookiesCollection = true; + } + else + return; + + ArrayList sessionStoredCookies = null; + for (int i=0; i < cookies.Count; i++) { + HttpCookie cookie = cookies[i]; + if (sessionCookies [cookie.Name] != null || inPortletMode) { + sessionCookies [cookie.Name] = cookie; + if (sessionStoredCookies == null) + sessionStoredCookies = new ArrayList(); + sessionStoredCookies. Add (cookie.Name); + } + } + + if (sessionStoredCookies != null) + foreach (object key in sessionStoredCookies) + cookies.Remove ((string) key); + + if (shouldStoreCookiesCollection) + javaSession.setAttribute (SessionCookies, sessionCookies); + } + } + } +} diff --git a/mcs/class/System.Web/System.Web/HttpResponse.cs b/mcs/class/System.Web/System.Web/HttpResponse.cs index e31e5ced5b5..e1029ecf690 100644 --- a/mcs/class/System.Web/System.Web/HttpResponse.cs +++ b/mcs/class/System.Web/System.Web/HttpResponse.cs @@ -39,6 +39,9 @@ using System.Web.Util; using System.Web.Configuration; using System.Globalization; using System.Security.Permissions; +#if TARGET_J2EE +using vmw.@internal.j2ee; +#endif namespace System.Web { @@ -382,6 +385,7 @@ namespace System.Web { suppress_content = value; } } + #if NET_2_0 [MonoTODO ("Not implemented")] public void AddCacheDependency (CacheDependency[] dependencies) @@ -657,8 +661,11 @@ namespace System.Web { int n = cookies.Count; for (int i = 0; i < n; i++) write_headers.Add (cookies.Get (i).GetCookieHeader ()); +#if TARGET_J2EE + // For J2EE Portal support emulate cookies by storing them in the session. + context.Request.SetSessionCookiesForPortal (cookies); +#endif } - } internal void WriteHeaders (bool final_flush) @@ -758,6 +765,19 @@ namespace System.Web { { if (headers_sent) throw new HttpException ("header have been already sent"); + +#if TARGET_J2EE + // In J2EE portal we need to handle Redirect at the processAction phase + // using the portlet ActionResponse that will send for us the redirect header. + IPortletActionResponse resp = context.ServletResponse as IPortletActionResponse; + if (resp != null) { + resp.sendRedirect (url); + if (endResponse) + End (); + return; + } +#endif + #if NET_2_0 is_request_being_redirected = true; #endif diff --git a/mcs/class/System.Web/System.Web20.vmwcsproj b/mcs/class/System.Web/System.Web20.vmwcsproj index 10c332e3b3b..0145e34b0bf 100644 --- a/mcs/class/System.Web/System.Web20.vmwcsproj +++ b/mcs/class/System.Web/System.Web20.vmwcsproj @@ -35,6 +35,7 @@ 2.0 1.5.0_05 0 + 67,168,169,219,414,612,618,649 true @@ -49,6 +50,7 @@ True False 0 + 67,168,169,219,414,612,618,649 @@ -64,6 +66,7 @@ false false 0 + 67,168,169,219,414,612,618,649 @@ -87,6 +90,7 @@ 2.0 1.5.0_05 0 + 67,168,169,219,414,612,618,649 @@ -848,6 +852,7 @@ + @@ -1036,6 +1041,9 @@ Code + + Code + Code @@ -1059,6 +1067,7 @@ + @@ -1195,6 +1204,9 @@ Code + + Code + @@ -1339,6 +1351,14 @@ + + False + ..\lib\j2ee.dll + + + False + ..\lib\J2EE.Helpers.dll + False ..\lib\J2SE.Helpers.dll @@ -1371,7 +1391,7 @@ --> - +