fix base/rest service - cleanup + new config file
This commit is contained in:
@@ -268,6 +268,12 @@
|
||||
<DependentUpon>ClientDependency.config</DependentUpon>
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<Content Include="config\BaseRestExtensions.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="config\BaseRestExtensions.Release.config">
|
||||
<DependentUpon>BaseRestExtensions.config</DependentUpon>
|
||||
</Content>
|
||||
<None Include="config\log4net.Release.config">
|
||||
<DependentUpon>log4net.config</DependentUpon>
|
||||
</None>
|
||||
@@ -2091,7 +2097,9 @@
|
||||
<Content Include="config\404handlers.config" />
|
||||
<Content Include="config\Dashboard.config" />
|
||||
<Content Include="config\metablogConfig.config" />
|
||||
<Content Include="config\restExtensions.config" />
|
||||
<Content Include="config\restExtensions.config">
|
||||
<SubType>Designer</SubType>
|
||||
</Content>
|
||||
<Content Include="config\tinyMceConfig.config" />
|
||||
<Content Include="config\umbracoSettings.config" />
|
||||
<Content Include="config\xsltExtensions.config" />
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<section name="Examine" type="Examine.Config.ExamineSettings, Examine" requirePermission="false"/>
|
||||
<section name="ExamineLuceneIndexSets" type="UmbracoExamine.Config.ExamineLuceneIndexes, UmbracoExamine" requirePermission="false"/>
|
||||
<section name="FileSystemProviders" type="Umbraco.Core.Configuration.FileSystemProvidersSection, Umbraco.Core" requirePermission="false"/>
|
||||
<section name="BaseRestExtensions" type="Umbraco.Web.BaseRest.Configuration.BaseRestSection, umbraco" requirePermission="false" />
|
||||
|
||||
<!-- Added in Umbraco 4.6.2 -->
|
||||
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
@@ -31,6 +32,7 @@
|
||||
<Examine configSource="config\ExamineSettings.config" />
|
||||
<ExamineLuceneIndexSets configSource="config\ExamineIndex.config" />
|
||||
<FileSystemProviders configSource="config\FileSystemProviders.config" />
|
||||
<BaseRestExtensions configSource="config\BaseRestExtensions.config" />
|
||||
|
||||
<appSettings>
|
||||
<add key="umbracoDbDSN" value="datalayer=MySql;server=localhost;database=umbraco;user id=root;password=root"/>
|
||||
|
||||
13
src/Umbraco.Web.UI/config/BaseRestExtensions.Release.config
Normal file
13
src/Umbraco.Web.UI/config/BaseRestExtensions.Release.config
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RestExtensions>
|
||||
<!--
|
||||
<ext assembly="umbraco" type="umbraco.presentation.umbracoBase.library.member" alias="currentMember">
|
||||
<permission method="login" allowAll="true" />
|
||||
<permission method="logout" allowAll="true" />
|
||||
<permission method="id" allowAll="true" />
|
||||
<permission method="data" allowAll="true" />
|
||||
<permission method="logout" allowAll="true" />
|
||||
<permission method="setProperty" allowAll="false" />
|
||||
</ext>
|
||||
-->
|
||||
</RestExtensions>
|
||||
17
src/Umbraco.Web.UI/config/BaseRestExtensions.config
Normal file
17
src/Umbraco.Web.UI/config/BaseRestExtensions.config
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<BaseRestExtensions>
|
||||
<extension alias="member" type="Umbraco.Web.BaseRest.MemberRest,umbraco">
|
||||
<method name="Login" allowAll="true" />
|
||||
<method name="Logout" allowAll="true" />
|
||||
<method name="GetCurrentMemberId" allowAll="true" />
|
||||
<method name="GetCurrentMember" allowAll="true" />
|
||||
<method name="GetCurrentMemberAsXml" allowAll="true" />
|
||||
<method name="SetProperty" allowAll="false" />
|
||||
</extension>
|
||||
<!--
|
||||
<extension alias="umbBlog" type="Runway.Blog.Library.Base,Runway.Blog">
|
||||
<method name="CreateComment" returnXml="false" allowAll="true" />
|
||||
<method name="GetGravatarImage" returnXml="false" allowAll="true" />
|
||||
</extension>
|
||||
-->
|
||||
</BaseRestExtensions>
|
||||
@@ -1,7 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- this is the pre-4.10 rest configuration -->
|
||||
<!-- you should use BaseRestExtensions.config instead -->
|
||||
<RestExtensions>
|
||||
<!--
|
||||
<ext assembly="/bin/umbraco" type="umbraco.presentation.umbracoBase.library.member" alias="currentMember">
|
||||
<!-- available for backward compatibility only -->
|
||||
<ext assembly="umbraco" type="umbraco.presentation.umbracoBase.library.member" alias="currentMember">
|
||||
<permission method="login" allowAll="true" />
|
||||
<permission method="logout" allowAll="true" />
|
||||
<permission method="id" allowAll="true" />
|
||||
@@ -9,8 +11,9 @@
|
||||
<permission method="logout" allowAll="true" />
|
||||
<permission method="setProperty" allowAll="false" />
|
||||
</ext>
|
||||
-->
|
||||
<ext assembly="Runway.Blog" type="Runway.Blog.Library.Base" alias="umbBlog">
|
||||
<!-- here for backward compatibility only -->
|
||||
<!-- because really, it should not be enabled by default -->
|
||||
<ext assembly="Runway.Blog" type="Runway.Blog.Library.Base" alias="umbBlog">
|
||||
<permission method="CreateComment" returnXml="false" allowAll="true" />
|
||||
<permission method="GetGravatarImage" returnXml="false" allowAll="true" />
|
||||
</ext>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
<section name="Examine" type="Examine.Config.ExamineSettings, Examine" requirePermission="false"/>
|
||||
<section name="ExamineLuceneIndexSets" type="UmbracoExamine.Config.ExamineLuceneIndexes, UmbracoExamine" requirePermission="false"/>
|
||||
<section name="FileSystemProviders" type="Umbraco.Core.Configuration.FileSystemProvidersSection, Umbraco.Core" requirePermission="false"/>
|
||||
<section name="BaseRestExtensions" type="Umbraco.Web.BaseRest.Configuration.BaseRestSection, umbraco" requirePermission="false" />
|
||||
|
||||
<!-- Added in Umbraco 4.6.2 -->
|
||||
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
|
||||
@@ -31,6 +32,7 @@
|
||||
<Examine configSource="config\ExamineSettings.config" />
|
||||
<ExamineLuceneIndexSets configSource="config\ExamineIndex.config" />
|
||||
<FileSystemProviders configSource="config\FileSystemProviders.config" />
|
||||
<BaseRestExtensions configSource="config\BaseRestExtensions.config" />
|
||||
|
||||
<appSettings>
|
||||
<add key="umbracoDbDSN" value="" />
|
||||
|
||||
17
src/Umbraco.Web/BaseRest/Configuration/BaseRestSection.cs
Normal file
17
src/Umbraco.Web/BaseRest/Configuration/BaseRestSection.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Umbraco.Web.BaseRest.Configuration
|
||||
{
|
||||
public class BaseRestSection : ConfigurationSection
|
||||
{
|
||||
[ConfigurationProperty("", IsKey = false, IsRequired = false, IsDefaultCollection = true)]
|
||||
public ExtensionElementCollection Items
|
||||
{
|
||||
get { return (ExtensionElementCollection)base[""]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
63
src/Umbraco.Web/BaseRest/Configuration/ExtensionElement.cs
Normal file
63
src/Umbraco.Web/BaseRest/Configuration/ExtensionElement.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Umbraco.Web.BaseRest.Configuration
|
||||
{
|
||||
[ConfigurationCollection(typeof(ExtensionElement), CollectionType = ConfigurationElementCollectionType.BasicMapAlternate)]
|
||||
public class ExtensionElement : ConfigurationElementCollection
|
||||
{
|
||||
const string Key_Alias = "alias";
|
||||
const string Key_Type = "type";
|
||||
const string Key_Method = "method";
|
||||
|
||||
[ConfigurationProperty(Key_Alias, IsKey = true, IsRequired = true)]
|
||||
public string Alias
|
||||
{
|
||||
get { return (string)base[Key_Alias]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(Key_Type, IsKey = false, IsRequired = true)]
|
||||
public string Type
|
||||
{
|
||||
get { return (string)base[Key_Type]; }
|
||||
}
|
||||
|
||||
public override ConfigurationElementCollectionType CollectionType
|
||||
{
|
||||
get { return ConfigurationElementCollectionType.BasicMapAlternate; }
|
||||
}
|
||||
|
||||
protected override string ElementName
|
||||
{
|
||||
get { return Key_Method; }
|
||||
}
|
||||
|
||||
protected override bool IsElementName(string elementName)
|
||||
{
|
||||
return elementName.Equals(Key_Method, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
protected override ConfigurationElement CreateNewElement()
|
||||
{
|
||||
return new MethodElement();
|
||||
}
|
||||
|
||||
protected override object GetElementKey(ConfigurationElement element)
|
||||
{
|
||||
return ((MethodElement)element).Name;
|
||||
}
|
||||
|
||||
public override bool IsReadOnly()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
new public MethodElement this[string index]
|
||||
{
|
||||
get { return (MethodElement)BaseGet(index); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Umbraco.Web.BaseRest.Configuration
|
||||
{
|
||||
[ConfigurationCollection(typeof(ExtensionElement), CollectionType = ConfigurationElementCollectionType.BasicMapAlternate)]
|
||||
public class ExtensionElementCollection : ConfigurationElementCollection
|
||||
{
|
||||
const string Key_Extension = "extension";
|
||||
|
||||
public override ConfigurationElementCollectionType CollectionType
|
||||
{
|
||||
get { return ConfigurationElementCollectionType.BasicMapAlternate; }
|
||||
}
|
||||
|
||||
protected override string ElementName
|
||||
{
|
||||
get { return Key_Extension; }
|
||||
}
|
||||
|
||||
protected override bool IsElementName(string elementName)
|
||||
{
|
||||
return elementName.Equals(Key_Extension, StringComparison.InvariantCultureIgnoreCase);
|
||||
}
|
||||
|
||||
protected override ConfigurationElement CreateNewElement()
|
||||
{
|
||||
return new ExtensionElement();
|
||||
}
|
||||
|
||||
protected override object GetElementKey(ConfigurationElement element)
|
||||
{
|
||||
return ((ExtensionElement)element).Alias;
|
||||
}
|
||||
|
||||
public override bool IsReadOnly()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
new public ExtensionElement this[string index]
|
||||
{
|
||||
get { return (ExtensionElement)BaseGet(index); }
|
||||
}
|
||||
}
|
||||
}
|
||||
54
src/Umbraco.Web/BaseRest/Configuration/MethodElement.cs
Normal file
54
src/Umbraco.Web/BaseRest/Configuration/MethodElement.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Configuration;
|
||||
|
||||
namespace Umbraco.Web.BaseRest.Configuration
|
||||
{
|
||||
public class MethodElement : ConfigurationElement
|
||||
{
|
||||
const string Key_Name = "name";
|
||||
const string Key_AllowAll = "allowAll";
|
||||
const string Key_AllowGroup = "allowGroup";
|
||||
const string Key_AllowType = "allowType";
|
||||
const string Key_AllowMember = "allowMember";
|
||||
const string Key_ReturnXml = "returnXml";
|
||||
|
||||
[ConfigurationProperty(Key_Name, IsKey = true, IsRequired = true)]
|
||||
public string Name
|
||||
{
|
||||
get { return (string)base[Key_Name]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(Key_AllowAll, IsKey = false, IsRequired = false, DefaultValue = false)]
|
||||
public bool AllowAll
|
||||
{
|
||||
get { return (bool)base[Key_AllowAll]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(Key_AllowGroup, IsKey = false, IsRequired = false, DefaultValue = null)]
|
||||
public string AllowGroup
|
||||
{
|
||||
get { return (string)base[Key_AllowGroup]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(Key_AllowType, IsKey = false, IsRequired = false, DefaultValue = null)]
|
||||
public string AllowType
|
||||
{
|
||||
get { return (string)base[Key_AllowType]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(Key_AllowMember, IsKey = false, IsRequired = false, DefaultValue = null)]
|
||||
public string AllowMember
|
||||
{
|
||||
get { return (string)base[Key_AllowMember]; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(Key_ReturnXml, IsKey = false, IsRequired = false, DefaultValue = true)]
|
||||
public bool ReturnXml
|
||||
{
|
||||
get { return (bool)base[Key_ReturnXml]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ using umbraco.cms.businesslogic.property;
|
||||
|
||||
namespace Umbraco.Web.BaseRest
|
||||
{
|
||||
public class MemberRest
|
||||
public static class MemberRest
|
||||
{
|
||||
public static int GetCurrentMemberId()
|
||||
{
|
||||
@@ -46,12 +46,6 @@ namespace Umbraco.Web.BaseRest
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Use Login(login, password).", false)]
|
||||
public static int login(string loginname, string password)
|
||||
{
|
||||
return Login(loginname, password);
|
||||
}
|
||||
|
||||
public static int Logout()
|
||||
{
|
||||
var currentId = GetCurrentMemberId();
|
||||
@@ -67,19 +61,7 @@ namespace Umbraco.Web.BaseRest
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Use Logout().", false)]
|
||||
public static int logout(int NodeId)
|
||||
{
|
||||
return Logout();
|
||||
}
|
||||
|
||||
[Obsolete("Use Logout().", false)]
|
||||
public static int logout()
|
||||
{
|
||||
return Logout();
|
||||
}
|
||||
|
||||
public static XPathNodeIterator Data()
|
||||
public static XPathNodeIterator GetCurrentMemberAsXml()
|
||||
{
|
||||
var m = GetCurrentMember();
|
||||
if (m != null)
|
||||
@@ -95,18 +77,6 @@ namespace Umbraco.Web.BaseRest
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Use Data().", false)]
|
||||
public static XPathNodeIterator data()
|
||||
{
|
||||
return Data();
|
||||
}
|
||||
|
||||
[Obsolete("Use GetCurrentMemberId().", false)]
|
||||
public static int id()
|
||||
{
|
||||
return GetCurrentMemberId();
|
||||
}
|
||||
|
||||
public static string SetProperty(string alias, object value)
|
||||
{
|
||||
string ret = "False";
|
||||
@@ -150,11 +120,5 @@ namespace Umbraco.Web.BaseRest
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
[Obsolete("Use SetProperty(alias, value).", false)]
|
||||
public static string setProperty(string alias, object value)
|
||||
{
|
||||
return SetProperty(alias, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
namespace Umbraco.Web.BaseRest
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
||||
public class RestExtensionAttribute : Attribute
|
||||
public sealed class RestExtensionAttribute : Attribute
|
||||
{
|
||||
public string Alias { get; private set; }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Text;
|
||||
namespace Umbraco.Web.BaseRest
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
||||
public class RestExtensionMethodAttribute : Attribute
|
||||
public sealed class RestExtensionMethodAttribute : Attribute
|
||||
{
|
||||
public bool AllowAll { get; set; }
|
||||
public string AllowGroup { get; set; }
|
||||
|
||||
@@ -72,19 +72,22 @@ namespace Umbraco.Web.BaseRest
|
||||
{
|
||||
return GetFromConfiguration(extensionAlias, methodName)
|
||||
?? GetFromAttribute(extensionAlias, methodName)
|
||||
?? GetFromLegacyAttribute(extensionAlias, methodName)
|
||||
?? GetFromLegacyConfiguration(extensionAlias, methodName) // that one should be obsoleted at some point
|
||||
?? GetFromLegacyAttribute(extensionAlias, methodName) // that one should be obsoleted at some point
|
||||
?? MissingMethod;
|
||||
}
|
||||
|
||||
// gets a RestExtensionMethodInfo matching extensionAlias and methodName
|
||||
// by looking at the configuration file
|
||||
// by looking at the legacy configuration file
|
||||
// returns null if not found
|
||||
//
|
||||
static RestExtensionMethodInfo GetFromConfiguration(string extensionAlias, string methodName)
|
||||
static RestExtensionMethodInfo GetFromLegacyConfiguration(string extensionAlias, string methodName)
|
||||
{
|
||||
const string ExtensionXPath = "/RestExtensions/ext [@alias='{0}']";
|
||||
const string MethodXPath = "./permission [@method='{0}']";
|
||||
|
||||
var config = (Configuration.BaseRestSection)System.Configuration.ConfigurationManager.GetSection("BaseRestExtensions");
|
||||
|
||||
// fixme - at the moment we reload the config file each time
|
||||
// we have to support live edits of the config file for backward compatibility reason
|
||||
// so if we want to cache, we'd also need to implement a watcher on the config file...
|
||||
@@ -102,13 +105,7 @@ namespace Umbraco.Web.BaseRest
|
||||
if (mNode == null)
|
||||
return null; // does not exist
|
||||
|
||||
// fixme - legacy loaded assemblies in the /bin folder using LoadFrom
|
||||
// which means that it is not possible to load App_Code
|
||||
// plus there is no point?
|
||||
|
||||
string assemblyName = eNode.Attributes["assembly"].Value;
|
||||
//string assemblyPath = IOHelper.MapPath(string.Format("{0}/{1}.dll", SystemDirectories.Bin, assemblyName.TrimStart('/')));
|
||||
//var assembly = Assembly.LoadFrom(assemblyPath);
|
||||
var assembly = Assembly.Load(assemblyName);
|
||||
|
||||
string typeName = eNode.Attributes["type"].Value;
|
||||
@@ -130,6 +127,49 @@ namespace Umbraco.Web.BaseRest
|
||||
return info;
|
||||
}
|
||||
|
||||
// gets a RestExtensionMethodInfo matching extensionAlias and methodName
|
||||
// by looking at the configuration file
|
||||
// returns null if not found
|
||||
//
|
||||
static RestExtensionMethodInfo GetFromConfiguration(string extensionAlias, string methodName)
|
||||
{
|
||||
var config = (Configuration.BaseRestSection)System.Configuration.ConfigurationManager.GetSection("BaseRestExtensions");
|
||||
|
||||
Configuration.ExtensionElement configExtension = config.Items[extensionAlias];
|
||||
if (configExtension == null)
|
||||
return null; // does not exist
|
||||
|
||||
Configuration.MethodElement configMethod = configExtension[methodName];
|
||||
if (configMethod == null)
|
||||
return null; // does not exist
|
||||
|
||||
MethodInfo method;
|
||||
try
|
||||
{
|
||||
var parts = configExtension.Type.Split(',');
|
||||
if (parts.Length > 2)
|
||||
throw new Exception(string.Format("Failed to load extension '{0}', invalid type."));
|
||||
|
||||
var assembly = parts.Length == 1 ? Assembly.GetExecutingAssembly() : Assembly.Load(parts[1]);
|
||||
var type = assembly.GetType(parts[0]);
|
||||
method = type.GetMethod(methodName);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception(string.Format("Failed to load extension '{0}', see inner exception.", configExtension.Type), e);
|
||||
}
|
||||
|
||||
if (method == null)
|
||||
return null; // does not exist
|
||||
|
||||
var info = new RestExtensionMethodInfo(configMethod.AllowAll,
|
||||
configMethod.AllowGroup, configMethod.AllowType, configMethod.AllowMember,
|
||||
configMethod.ReturnXml,
|
||||
method);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
// gets a RestExtensionMethodInfo matching extensionAlias and methodName
|
||||
// by looking for the legacy attributes
|
||||
// returns null if not found
|
||||
@@ -281,90 +321,76 @@ namespace Umbraco.Web.BaseRest
|
||||
// ensure that method is static public
|
||||
return "<error>Method has to be public and static</error>";
|
||||
}
|
||||
|
||||
// ensure we have the right number of parameters
|
||||
if (_method.GetParameters().Length != parameters.Length)
|
||||
{
|
||||
return "<error>Not Enough parameters in url</error>";
|
||||
}
|
||||
|
||||
// invoke
|
||||
|
||||
object response;
|
||||
|
||||
if (_method.GetParameters().Length == 0)
|
||||
{
|
||||
response = _method.Invoke(null, null); // invoke with null as parameters as there are none
|
||||
}
|
||||
else
|
||||
{
|
||||
// ensure we have the right number of parameters
|
||||
if (_method.GetParameters().Length != parameters.Length)
|
||||
object[] methodParams = new object[parameters.Length];
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (ParameterInfo pInfo in _method.GetParameters())
|
||||
{
|
||||
return "<error>Not Enough parameters in url</error>";
|
||||
Type myType = Type.GetType(pInfo.ParameterType.ToString());
|
||||
methodParams[(i)] = Convert.ChangeType(parameters[i], myType);
|
||||
i++;
|
||||
}
|
||||
else
|
||||
|
||||
response = _method.Invoke(null, methodParams);
|
||||
}
|
||||
|
||||
// this is legacy and could probably be improved
|
||||
if (response != null)
|
||||
{
|
||||
switch (_method.ReturnType.ToString())
|
||||
{
|
||||
// invoke
|
||||
case "System.Xml.XPath.XPathNodeIterator":
|
||||
return ((System.Xml.XPath.XPathNodeIterator)response).Current.OuterXml;
|
||||
case "System.Xml.Linq.XDocument":
|
||||
return response.ToString();
|
||||
case "System.Xml.XmlDocument":
|
||||
XmlDocument xmlDoc = (XmlDocument)response;
|
||||
StringWriter sw = new StringWriter();
|
||||
XmlTextWriter xw = new XmlTextWriter(sw);
|
||||
xmlDoc.WriteTo(xw);
|
||||
return sw.ToString();
|
||||
default:
|
||||
string strResponse = (string)response.ToString();
|
||||
|
||||
// fixme - what is the point?
|
||||
//Create an instance of the type we need to invoke the method from.
|
||||
//**Object obj = Activator.CreateInstance(myExtension.type);
|
||||
|
||||
object response;
|
||||
|
||||
if (_method.GetParameters().Length == 0)
|
||||
{
|
||||
//response = myMethod.method.Invoke(obj, BindingFlags.Public | BindingFlags.Instance, bBinder, null, System.Globalization.CultureInfo.CurrentCulture);
|
||||
response = _method.Invoke(null /*obj*/, null); // invoke with null as parameters as there are none
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
object[] methodParams = new object[parameters.Length];
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (ParameterInfo pInfo in _method.GetParameters())
|
||||
{
|
||||
Type myType = Type.GetType(pInfo.ParameterType.ToString());
|
||||
methodParams[(i)] = Convert.ChangeType(parameters[i], myType);
|
||||
i++;
|
||||
}
|
||||
|
||||
//Invoke with methodParams
|
||||
//response = myMethod.method.Invoke(obj, BindingFlags.Public | BindingFlags.Instance, bBinder, methodParams, System.Globalization.CultureInfo.CurrentCulture);
|
||||
response = _method.Invoke(/*obj*/null, methodParams);
|
||||
}
|
||||
|
||||
/*TODO - SOMETHING ALITTLE BETTER THEN ONLY CHECK FOR XPATHNODEITERATOR OR ELSE do ToString() */
|
||||
if (response != null)
|
||||
{
|
||||
switch (_method.ReturnType.ToString())
|
||||
{
|
||||
case "System.Xml.XPath.XPathNodeIterator":
|
||||
return ((System.Xml.XPath.XPathNodeIterator)response).Current.OuterXml;
|
||||
case "System.Xml.Linq.XDocument":
|
||||
return response.ToString();
|
||||
case "System.Xml.XmlDocument":
|
||||
XmlDocument xmlDoc = (XmlDocument)response;
|
||||
StringWriter sw = new StringWriter();
|
||||
XmlTextWriter xw = new XmlTextWriter(sw);
|
||||
xmlDoc.WriteTo(xw);
|
||||
return sw.ToString();
|
||||
default:
|
||||
string strResponse = ((string)response.ToString());
|
||||
|
||||
if (this.ReturnXml)
|
||||
{
|
||||
// do a quick "is this html?" check... if it is add CDATA...
|
||||
if (strResponse.Contains("<") || strResponse.Contains(">"))
|
||||
strResponse = "<![CDATA[" + strResponse + "]]>";
|
||||
return "<value>" + strResponse + "</value>";
|
||||
}
|
||||
else
|
||||
{
|
||||
//HttpContext.Current.Response.ContentType = "text/html";
|
||||
return strResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.ReturnXml)
|
||||
return "<error>Null value returned</error>";
|
||||
{
|
||||
// do a quick "is this html?" check... if it is add CDATA...
|
||||
if (strResponse.Contains("<") || strResponse.Contains(">"))
|
||||
strResponse = "<![CDATA[" + strResponse + "]]>";
|
||||
return "<value>" + strResponse + "</value>";
|
||||
}
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
{
|
||||
return strResponse;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.ReturnXml)
|
||||
return "<error>Null value returned</error>";
|
||||
else
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
{
|
||||
//Overall exception handling...
|
||||
|
||||
@@ -240,7 +240,11 @@
|
||||
<Link>Properties\SolutionInfo.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="ApplicationEventsResolver.cs" />
|
||||
<Compile Include="BaseRest\Configuration\BaseRestSection.cs" />
|
||||
<Compile Include="BaseRest\BaseRestHandler.cs" />
|
||||
<Compile Include="BaseRest\Configuration\ExtensionElement.cs" />
|
||||
<Compile Include="BaseRest\Configuration\ExtensionElementCollection.cs" />
|
||||
<Compile Include="BaseRest\Configuration\MethodElement.cs" />
|
||||
<Compile Include="BaseRest\MemberRest.cs" />
|
||||
<Compile Include="BaseRest\RestExtensionAttribute.cs" />
|
||||
<Compile Include="BaseRest\RestExtensionMethodAttribute.cs" />
|
||||
@@ -1831,6 +1835,7 @@
|
||||
<DependentUpon>Reference.map</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WebServices\FolderBrowserService.cs" />
|
||||
<Content Include="umbraco.presentation\umbracobase\readme.txt" />
|
||||
<Content Include="umbraco.presentation\umbraco\controls\Tree\CustomTreeService.asmx" />
|
||||
<Content Include="umbraco.presentation\umbraco\developer\RelationTypes\EditRelationType.aspx" />
|
||||
<Content Include="umbraco.presentation\umbraco\developer\RelationTypes\NewRelationType.aspx" />
|
||||
|
||||
@@ -17,33 +17,27 @@ using umbraco.cms.businesslogic.property;
|
||||
|
||||
namespace umbraco.presentation.umbracobase.library
|
||||
{
|
||||
//This should be replaced with umbracos own methods...
|
||||
[Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.")]
|
||||
public class library
|
||||
{
|
||||
public static Member GetCurrentMember()
|
||||
[Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.GetCurrentMember().", false)]
|
||||
public static Member GetCurrentMember()
|
||||
{
|
||||
// zb-00035 #29931 : remove duplicate code?
|
||||
return Member.GetCurrentMember();
|
||||
}
|
||||
|
||||
[Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.GetCurrentMemberId().", false)]
|
||||
public static int CurrentMemberId()
|
||||
{
|
||||
// zb-00035 #29931 : remove duplicate code?
|
||||
return Member.CurrentMemberId();
|
||||
}
|
||||
}
|
||||
|
||||
public class test
|
||||
{
|
||||
public static int member()
|
||||
{
|
||||
return Member.CurrentMemberId();
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.")]
|
||||
public class member
|
||||
{
|
||||
public static int login(string loginname, string password)
|
||||
[Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.Login(login, password).", false)]
|
||||
public static int login(string loginname, string password)
|
||||
{
|
||||
Member m = Member.GetMemberFromLoginNameAndPassword(loginname, password);
|
||||
|
||||
@@ -62,7 +56,7 @@ namespace umbraco.presentation.umbracobase.library
|
||||
return library.CurrentMemberId();
|
||||
}
|
||||
|
||||
[Obsolete("Deprecated, use logout(int NodeId) instead", false)]
|
||||
[Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.Logout().", false)]
|
||||
public static int logout()
|
||||
{
|
||||
Member m = library.GetCurrentMember();
|
||||
@@ -76,7 +70,8 @@ namespace umbraco.presentation.umbracobase.library
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int logout(int NodeId)
|
||||
[Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.Logout().", false)]
|
||||
public static int logout(int NodeId)
|
||||
{
|
||||
int _currentMemberId = library.CurrentMemberId();
|
||||
if (_currentMemberId > 0)
|
||||
@@ -89,7 +84,8 @@ namespace umbraco.presentation.umbracobase.library
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static XPathNodeIterator data()
|
||||
[Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.GetCurrentMemberAsXml().", false)]
|
||||
public static XPathNodeIterator data()
|
||||
{
|
||||
if (library.GetCurrentMember() != null)
|
||||
{
|
||||
@@ -102,12 +98,14 @@ namespace umbraco.presentation.umbracobase.library
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int id()
|
||||
[Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.GetCurrentMemberId().", false)]
|
||||
public static int id()
|
||||
{
|
||||
return library.CurrentMemberId();
|
||||
}
|
||||
|
||||
public static string setProperty(string alias, object value)
|
||||
[Obsolete("Deprecated, use Umbraco.Web.BaseRest.MemberRest.SetProperty(alias, value).", false)]
|
||||
public static string setProperty(string alias, object value)
|
||||
{
|
||||
string retVal = "False";
|
||||
try
|
||||
|
||||
17
src/Umbraco.Web/umbraco.presentation/umbracobase/readme.txt
Normal file
17
src/Umbraco.Web/umbraco.presentation/umbracobase/readme.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
Umbraco Base Rest Handler
|
||||
-------------------------
|
||||
|
||||
The Umbraco Base Rest Handler has moved to Umbraco.Web.BaseRest.
|
||||
|
||||
At the moment, both the legacy way and the new way of doing things are supported.
|
||||
The baseHttpModule does _not_ run anymore, everything is handled by
|
||||
Umbraco.Web.BaseRest, but the legacy attributes and config files are supported,
|
||||
so legacy extensions are discovered and will run properly.
|
||||
|
||||
However, you should start using the attributes in Umbraco.Web.BaseRest, and the
|
||||
new BaseRestExtensions.config config file.
|
||||
|
||||
The legacy system will be obsoleted at some point in the future and all references
|
||||
to the code legacy will be removed.
|
||||
|
||||
--
|
||||
Reference in New Issue
Block a user