Merge with 6.0.5

This commit is contained in:
Sebastiaan Janssen
2013-04-29 12:31:13 -02:00
29 changed files with 2 additions and 2319 deletions

View File

@@ -63,8 +63,6 @@
<file src="..\_BuildOutput\WebApp\bin\umbraco.providers.dll" target="lib\umbraco.providers.dll" />
<file src="..\_BuildOutput\WebApp\bin\umbraco.providers.xml" target="lib\umbraco.providers.xml" />
<file src="..\_BuildOutput\WebApp\bin\Umbraco.Web.UI.dll" target="lib\Umbraco.Web.UI.dll" />
<file src="..\_BuildOutput\WebApp\bin\umbraco.webservices.dll" target="lib\umbraco.webservices.dll" />
<file src="..\_BuildOutput\WebApp\bin\umbraco.webservices.xml" target="lib\umbraco.webservices.xml" />
<file src="..\_BuildOutput\WebApp\bin\umbraco.XmlSerializers.dll" target="lib\umbraco.XmlSerializers.dll" />
<file src="..\_BuildOutput\WebApp\bin\UmbracoExamine.dll" target="lib\UmbracoExamine.dll" />
<file src="..\_BuildOutput\WebApp\bin\UrlRewritingNet.UrlRewriter.dll" target="lib\UrlRewritingNet.UrlRewriter.dll" />

View File

@@ -29,11 +29,11 @@ using System.Security.Permissions;
[assembly: InternalsVisibleTo("businesslogic")]
[assembly: InternalsVisibleTo("cms")]
[assembly: InternalsVisibleTo("umbraco.editorControls")]
[assembly: InternalsVisibleTo("umbraco.webservices")]
[assembly: InternalsVisibleTo("umbraco.datalayer")]
[assembly: InternalsVisibleTo("umbraco.MacroEngines")]
[assembly: InternalsVisibleTo("umbraco.editorControls")]
[assembly: InternalsVisibleTo("umbraco.webservices")]
[assembly: InternalsVisibleTo("Umbraco.Tests")]
[assembly: InternalsVisibleTo("Umbraco.Core")]
[assembly: InternalsVisibleTo("Umbraco.Web")]

View File

@@ -268,7 +268,7 @@ namespace Umbraco.Core
"umbraco.interfaces,",
"umbraco.providers,",
"Umbraco.Web.UI,",
"umbraco.webservices",
"umbraco.webservices",
"Lucene.",
"Examine,",
"Examine.",

View File

@@ -1 +0,0 @@
<%@ WebService Language="C#" CodeBehind="DocumentService.asmx.cs" Class="umbraco.webservices.documents.documentService" %>

View File

@@ -1 +0,0 @@
<%@ WebService Language="C#" CodeBehind="FileService.asmx.cs" Class="umbraco.webservices.files.fileService" %>

View File

@@ -1 +0,0 @@
<%@ WebService Language="C#" CodeBehind="MaintanceService.asmx.cs" Class="umbraco.webservices.maintenance.maintenanceService" %>

View File

@@ -1 +0,0 @@
<%@ WebService Language="C#" CodeBehind="MediaService.asmx.cs" Class="umbraco.webservices.media.mediaService" %>

View File

@@ -1 +0,0 @@
<%@ WebService Language="C#" CodeBehind="MemberService.asmx.cs" Class="umbraco.webservices.members.memberService" %>

View File

@@ -1 +0,0 @@
<%@ WebService Language="C#" CodeBehind="StylesheetService.asmx.cs" Class="umbraco.webservices.stylesheets.stylesheetService" %>

View File

@@ -1 +0,0 @@
<%@ WebService Language="C#" CodeBehind="TemplateService.asmx.cs" Class="umbraco.webservices.templates.templateService" %>

View File

@@ -34,8 +34,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "umbraco.datalayer", "umbrac
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "umbraco.controls", "umbraco.controls\umbraco.controls.csproj", "{6EDD2061-82F2-461B-BB6E-879245A832DE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "umbraco.webservices", "umbraco.webservices\umbraco.webservices.csproj", "{CBDB56AC-FF02-4421-9FD4-ED82E339D8E2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlCE4Umbraco", "SQLCE4Umbraco\SqlCE4Umbraco.csproj", "{5BA5425F-27A7-4677-865E-82246498AA2E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "umbraco.MacroEngines", "umbraco.MacroEngines\umbraco.MacroEngines.csproj", "{89C09045-1064-466B-B94A-DB3AFE2A5853}"

View File

@@ -1,199 +0,0 @@
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Services;
using System.Web.Services.Protocols;
using Umbraco.Core.Logging;
using umbraco.BasePages;
using umbraco.BusinessLogic;
using System.IO;
namespace umbraco.webservices
{
/// <summary>
/// The base-class all webservices should inherit from
/// </summary>
/// <remarks>
/// This class contains all basic methods for authenticating requests. Do not implement these functions yourself.
/// </remarks>
public abstract class BaseWebService : System.Web.Services.WebService
{
public abstract Services Service
{
get;
}
/// <summary>
/// Enum of services available
/// </summary>
public enum Services
{
DocumentService,
FileService,
StylesheetService,
MemberService,
MaintenanceService,
TemplateService,
MediaService
};
/// <summary>
/// Gets the umbraco-user from username and password
/// </summary>
public umbraco.BusinessLogic.User GetUser(string username, string password)
{
User u = new User(username);
if(!HttpContext.Current.Request.Url.Scheme.Equals("https"))
{
LogHelper.Debug<BaseWebService>("Webservices login attempted without https");
}
try
{
if (Membership.Providers[UmbracoSettings.DefaultBackofficeProvider].ValidateUser(username, password))
{
LogHelper.Info<BaseWebService>("User {0} (Id: {1}) logged in", () => u.Name, () => u.Id);
return u;
}
}
catch
{
}
return null;
}
/// <summary>
/// Standart user-validation. All services must perform this
/// </summary>
public void Authenticate(string username, string password)
{
if (!WebservicesEnabled()) throw new Exception("Webservices not enabled");
if (!UserAuthenticates(username, password)) throw new Exception("The user does not authenticate");
if (!UserHasAccess(username)) throw new Exception("The user (" + username + ") does not have access to this service");
}
[WebMethod]
public bool WebservicesEnabled()
{
return umbraco.UmbracoSettings.Webservices.Enabled;
}
[WebMethod]
public bool UserAuthenticates(string username, string password)
{
if (!WebservicesEnabled()) throw new Exception("Webservices not enabled");
return GetUser(username, password) != null;
}
/// <summary>
/// Checks if a user has access to a specific webservice
/// </summary>
[WebMethod]
public bool UserHasAccess(string username)
{
switch (Service)
{
case Services.DocumentService:
return -1 < Array.IndexOf<string>(umbraco.UmbracoSettings.Webservices.documentServiceUsers, username);
case Services.FileService:
return -1 < Array.IndexOf<string>(umbraco.UmbracoSettings.Webservices.fileServiceUsers, username);
case Services.StylesheetService:
return -1 < Array.IndexOf<string>(umbraco.UmbracoSettings.Webservices.stylesheetServiceUsers, username);
case Services.MemberService:
return -1 < Array.IndexOf<string>(umbraco.UmbracoSettings.Webservices.memberServiceUsers, username);
case Services.MaintenanceService:
return -1 < Array.IndexOf<string>(umbraco.UmbracoSettings.Webservices.maintenanceServiceUsers, username);
case Services.TemplateService:
return -1 < Array.IndexOf<string>(umbraco.UmbracoSettings.Webservices.templateServiceUsers, username);
case Services.MediaService:
return -1 < Array.IndexOf<string>(umbraco.UmbracoSettings.Webservices.mediaServiceUsers, username);
default:
return false;
}
}
public class FileIO
{
/// <summary>
/// Validates a filename. Must be used when user inputs a filename
/// </summary>
public static bool ValidFileName(string fileName)
{
// Check if a "levelup" string is included, so they dont move out of the folder
// Dont know if its necesary?
if (fileName.IndexOf("..") > -1)
return false;
return true;
}
/// <summary>
/// Checks if user has access to a specific folder
/// </summary>
public static bool FolderAccess(String folderName)
{
// Check if the folder is in "fileServiceFolders"
if (Array.IndexOf<string>(umbraco.UmbracoSettings.Webservices.fileServiceFolders, folderName) > -1)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// Gets the webservers path for a file
/// </summary>
public static string GetFilePath(string folderName, string fileName)
{
string FullPath = GetFolderPath(folderName) + fileName;
return FullPath;
}
/// <summary>
/// Gets the webservers path for a folder
/// </summary>
public static string GetFolderPath(string folderName)
{
if (string.IsNullOrEmpty(folderName))
{
return AppRoot;
}
else
{
return AppRoot + folderName + @"\";
}
}
/// <summary>
/// Gets the webservers path for the application
/// </summary>
public static string AppRoot
{
get
{
return System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;
}
}
}
}
}

View File

@@ -1,108 +0,0 @@
//using System;
//using System.Data;
//using System.Configuration;
//using System.Web;
//using System.Web.Security;
//using System.Web.UI;
//using System.Web.UI.WebControls;
//using System.Web.UI.WebControls.WebParts;
//using System.Web.UI.HtmlControls;
//using System.Xml.Serialization;
//using System.Xml;
//namespace umbraco.webservices
//{
// public class authentication
// {
// /// <summary>
// /// Standart user-validation. All services must perform this
// /// </summary>
// /// <param name="username"></param>
// /// <param name="password"></param>
// /// <param name="service"></param>
// /// <remarks>First checks if the webservices are enabled. Then checks if the user is valid
// /// (username and password). Finally it checks if the user has access to the specific service
// /// </remarks>
// public static void StandartRequestCheck(string username, string password, authentication.EService service)
// {
// // We check if services are enabled and user has access
// if (!umbraco.UmbracoSettings.Webservices.Enabled)
// throw new Exception("webservices not enabled");
// // Validating the user
// GetUser(username, password);
// // Checking if user can use that specific service
// if (!authentication.UserHasAccess(username, service))
// throw new Exception("user has not access to this service");
// }
// /// <summary>
// /// Gets the umbraco-user from username and password
// /// </summary>
// /// <param name="username"></param>
// /// <param name="password"></param>
// /// <returns></returns>
// public static umbraco.BusinessLogic.User GetUser(string username, string password)
// {
// umbraco.BusinessLogic.User user;
// try
// {
// user = new umbraco.BusinessLogic.User(username, password);
// if (user == null)
// throw new Exception("Incorrect credentials. No user found. Call aborted");
// }
// catch (Exception ex)
// {
// throw new Exception("Incorrect credentials. Call aborted (error: " + ex.Message + Environment.NewLine + Environment.NewLine + ex.StackTrace + ")");
// }
// return user;
// }
// /// <summary>
// /// List of accesible the services
// /// </summary>
// public enum EService
// {
// DocumentService,
// FileService,
// StylesheetService,
// MemberService,
// MaintenanceService,
// TemplateService
// };
// /// <summary>
// /// Checks if a user has access to a specific webservice
// /// </summary>
// /// <param name="username">user to check</param>
// /// <param name="service">the webservice to check for</param>
// /// <returns>true, if user has access otherwise false</returns>
// public static bool UserHasAccess(string username, EService service)
// {
// switch (service)
// {
// case EService.DocumentService:
// return -1 < Array.IndexOf<string>(umbraco.UmbracoSettings.Webservices.documentServiceUsers, username);
// case EService.FileService:
// return -1 < Array.IndexOf<string>(umbraco.UmbracoSettings.Webservices.fileServiceUsers, username);
// case EService.StylesheetService:
// return -1 < Array.IndexOf<string>(umbraco.UmbracoSettings.Webservices.stylesheetServiceUsers, username);
// case EService.MemberService :
// return -1 < Array.IndexOf<string>(umbraco.UmbracoSettings.Webservices.memberServiceUsers, username);
// case EService.MaintenanceService:
// return -1 < Array.IndexOf<string>(umbraco.UmbracoSettings.Webservices.maintenanceServiceUsers, username);
// case EService.TemplateService :
// return -1 < Array.IndexOf<string>(umbraco.UmbracoSettings.Webservices.templateServiceUsers, username);
// default:
// return false;
// }
// }
// }
//}

View File

@@ -1,19 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("umbraco.webservices")]
[assembly: AssemblyDescription("Core assembly containing webservices")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("Umbraco CMS")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("58e13174-1338-40a8-b864-f47c7678a976")]

View File

@@ -1,105 +0,0 @@
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
namespace umbraco.webservices.documents
{
[Serializable]
[XmlType(Namespace = "http://umbraco.org/webservices/")]
public class documentCarrier
{
public enum EPublishAction
{
Ignore,
Publish,
Unpublish
};
public enum EPublishStatus
{
Published,
NotPublished
};
public documentCarrier()
{
DocumentProperties = new List<documentProperty>();
}
private int id;
private string name;
private List<documentProperty> documentProperties;
private int documentTypeID;
private int parentID;
private bool hasChildren;
private EPublishAction publishAction;
private bool published;
private DateTime releaseDate;
private DateTime expireDate;
public int Id
{
get { return id; }
set { id = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
public List<documentProperty> DocumentProperties
{
get { return documentProperties; }
set { documentProperties = value; }
}
public int DocumentTypeID
{
get { return documentTypeID; }
set { documentTypeID = value; }
}
public int ParentID
{
get { return parentID; }
set { parentID = value; }
}
public bool HasChildren
{
get { return hasChildren; }
set { hasChildren = value; }
}
public EPublishAction PublishAction
{
get { return publishAction; }
set { publishAction = value; }
}
public bool Published
{
get { return published; }
set { published = value; }
}
public DateTime ReleaseDate
{
get { return releaseDate; }
set { releaseDate = value; }
}
public DateTime ExpireDate
{
get { return expireDate; }
set { expireDate = value; }
}
}
}

View File

@@ -1,29 +0,0 @@
using System;
using System.Xml.Serialization;
namespace umbraco.webservices.documents
{
[Serializable]
[XmlType(Namespace = "http://umbraco.org/webservices/")]
public class documentProperty
{
private string key;
private object propertyValue;
public documentProperty()
{
}
public object PropertyValue
{
get { return propertyValue; }
set { propertyValue = value; }
}
public string Key
{
get { return key; }
set { key = value; }
}
}
}

View File

@@ -1,306 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web.Services;
using umbraco.cms.businesslogic.web;
namespace umbraco.webservices.documents
{
/// <summary>
/// Service managing documents in umbraco
/// </summary>
[WebService(Namespace = "http://umbraco.org/webservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class documentService : BaseWebService
{
override public Services Service
{
get
{
return Services.DocumentService;
}
}
[WebMethod]
public int create(documentCarrier carrier, string username, string password)
{
Authenticate(username, password);
// Some validation
if (carrier == null) throw new Exception("No carrier specified");
if (carrier.ParentID == 0) throw new Exception("Document needs a parent");
if (carrier.DocumentTypeID == 0) throw new Exception("Documenttype must be specified");
if (carrier.Id != 0) throw new Exception("ID cannot be specifed when creating. Must be 0");
if (string.IsNullOrEmpty(carrier.Name)) carrier.Name = "unnamed";
var user = GetUser(username, password);
// We get the documenttype
var docType = new DocumentType(carrier.DocumentTypeID);
if (docType == null) throw new Exception("DocumenttypeID " + carrier.DocumentTypeID + " not found");
// We create the document
var newDoc = Document.MakeNew(carrier.Name, docType, user, carrier.ParentID);
newDoc.ReleaseDate = carrier.ReleaseDate;
newDoc.ExpireDate = carrier.ExpireDate;
// We iterate the properties in the carrier
if (carrier.DocumentProperties != null)
{
foreach (var updatedproperty in carrier.DocumentProperties)
{
var property = newDoc.getProperty(updatedproperty.Key);
if (property == null) throw new Exception("property " + updatedproperty.Key + " was not found");
property.Value = updatedproperty.PropertyValue;
}
}
// We check the publish action and do the appropiate
handlePublishing(newDoc, carrier, user);
// We return the ID of the document..65
return newDoc.Id;
}
[WebMethod]
public documentCarrier read(int id, string username, string password)
{
Authenticate(username, password);
umbraco.cms.businesslogic.web.Document doc = null;
try
{
doc = new umbraco.cms.businesslogic.web.Document(id);
}
catch
{ }
if (doc == null)
throw new Exception("Could not load Document with ID: " + id);
documentCarrier carrier = createCarrier(doc);
return carrier;
}
[WebMethod]
public documentCarrier ReadPublished(int id, string username, string password)
{
Authenticate(username, password);
var doc = new Document(id, true);
var publishedDoc = doc.GetPublishedVersion();
doc = publishedDoc == null ? new Document(id) : new Document(id, publishedDoc.Version);
if (doc == null)
throw new Exception("Could not load Document with ID: " + id);
return createCarrier(doc);
}
[WebMethod]
public List<documentCarrier> readList(int parentid, string username, string password)
{
Authenticate(username, password);
umbraco.cms.businesslogic.web.Document[] docList;
umbraco.cms.businesslogic.web.Document doc = null;
List<documentCarrier> carriers = new List<documentCarrier>();
if (parentid == 0)
{
docList = Document.GetRootDocuments();
}
else
{
try
{
doc = new umbraco.cms.businesslogic.web.Document(parentid);
}
catch
{ }
if (doc == null)
throw new Exception("Parent document with ID " + parentid + " not found");
try
{
if (!doc.HasChildren)
return carriers;
docList = doc.Children;
}
catch (Exception exception)
{
throw new Exception("Could not load children: " + exception.Message);
}
}
// Loop the nodes in docList
foreach (Document childdoc in docList)
{
carriers.Add(createCarrier(childdoc));
}
return carriers;
}
[WebMethod]
public void update(documentCarrier carrier, string username, string password)
{
Authenticate(username, password);
if (carrier.Id == 0) throw new Exception("ID must be specifed when updating");
if (carrier == null) throw new Exception("No carrier specified");
umbraco.BusinessLogic.User user = GetUser(username, password);
Document doc = null;
try
{
doc = new Document(carrier.Id);
}
catch { }
if (doc == null)
// We assign the new values:
doc.ReleaseDate = carrier.ReleaseDate;
doc.ExpireDate = carrier.ExpireDate;
if (carrier.ParentID != 0)
{
doc.Move(carrier.ParentID);
}
if (carrier.Name.Length != 0)
{
doc.Text = carrier.Name;
}
// We iterate the properties in the carrier
if (carrier.DocumentProperties != null)
{
foreach (documentProperty updatedproperty in carrier.DocumentProperties)
{
umbraco.cms.businesslogic.property.Property property = doc.getProperty(updatedproperty.Key);
if (property == null)
{
}
else
{
property.Value = updatedproperty.PropertyValue;
}
}
}
handlePublishing(doc, carrier, user);
}
[WebMethod]
public void delete(int id, string username, string password)
{
Authenticate(username, password);
// Some validation, to prevent deletion of system-documents.. (nessecary?)
if (id < 0)
{
throw new Exception("Cannot delete documents with id lower than 1");
}
// We load the document
Document doc = null;
try
{
doc = new Document(id);
}
catch
{ }
if (doc == null)
throw new Exception("Document not found");
try
{
doc.delete();
}
catch (Exception ex)
{
throw new Exception("Document could not be deleted" + ex.Message);
}
}
private void handlePublishing(Document doc, documentCarrier carrier, umbraco.BusinessLogic.User user)
{
switch (carrier.PublishAction)
{
case documentCarrier.EPublishAction.Publish:
doc.SaveAndPublish(user);
break;
case documentCarrier.EPublishAction.Unpublish:
doc.UnPublish();
break;
case documentCarrier.EPublishAction.Ignore:
if (doc.Published)
{
doc.UnPublish();
}
else
{
doc.SaveAndPublish(user);
}
break;
}
}
private documentCarrier createCarrier(Document doc)
{
documentCarrier carrier = new documentCarrier();
carrier.ExpireDate = doc.ExpireDate;
carrier.ReleaseDate = doc.ReleaseDate;
carrier.Id = doc.Id;
carrier.Name = doc.Text;
try
{
carrier.ParentID = doc.Parent.Id;
}
catch
{
}
carrier.Published = doc.Published;
carrier.HasChildren = doc.HasChildren;
var props = doc.GenericProperties;
foreach (umbraco.cms.businesslogic.property.Property prop in props)
{
documentProperty carrierprop = new documentProperty();
if (prop.Value == System.DBNull.Value)
{
carrierprop.PropertyValue = null;
}
else
{
carrierprop.PropertyValue = prop.Value;
}
carrierprop.Key = prop.PropertyType.Alias;
carrier.DocumentProperties.Add(carrierprop);
}
return carrier;
}
}
}

View File

@@ -1,190 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Web.Services;
namespace umbraco.webservices.files
{
/// <summary>
/// Summary description for FileService
/// </summary>
[WebService(Namespace = "http://umbraco.org/webservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class fileService : BaseWebService
{
override public Services Service
{
get
{
return Services.FileService;
}
}
[WebMethod]
public void DeleteFile(String folderName, string fileName, string username, string password)
{
Authenticate(username, password);
// Check if folder is accessible
if (FileIO.FolderAccess(folderName))
{
// Check if the filename is valid
if (!FileIO.ValidFileName(fileName))
throw new ArgumentException(String.Format("Filename {0} not valid", fileName));
// Check if the file exists. If it does, we delete it
if (System.IO.File.Exists(FileIO.GetFilePath(folderName, fileName)))
{
System.IO.File.Delete(FileIO.GetFilePath(folderName, fileName));
}
else
{
throw new FileNotFoundException();
}
}
else
{
throw new ArgumentException("no access to specified folder");
}
}
[WebMethod]
public Byte[] DownloadFile(String folderName, string fileName, string username, string password)
{
Authenticate(username, password);
// Check if folder is accessible
if (FileIO.FolderAccess(folderName))
{
// Check if the filename is valid
if (!FileIO.ValidFileName(fileName))
throw new ArgumentException(String.Format("Filename {0} not valid", fileName));
// Check if the file even exists
if (!System.IO.File.Exists(FileIO.GetFilePath(folderName, fileName)))
{
throw new FileNotFoundException("Could not find file to delete");
}
// Create a stream, and send it to the client
FileStream objfilestream = new FileStream(FileIO.GetFilePath(folderName, fileName), FileMode.Open, FileAccess.Read);
int len = (int)objfilestream.Length;
Byte[] documentcontents = new Byte[len];
objfilestream.Read(documentcontents, 0, len);
objfilestream.Close();
return documentcontents;
}
else
{
throw new ArgumentException("no access to specified folder");
}
}
[WebMethod]
public void UploadFile(Byte[] docbinaryarray, String folderName, string fileName, string username, string password, bool deleteOld)
{
Authenticate(username, password);
// Check if folder is accessible
if (FileIO.FolderAccess(folderName))
{
// Check if the filename is valid
if (FileIO.ValidFileName(fileName))
throw new ArgumentException(String.Format("Filename {0} not valid", fileName));
// Check if the file exists. If it does, we delete it first ..
// TODO: Maybe we should have "deleted files, folder for this?
if (System.IO.File.Exists(FileIO.GetFilePath(folderName, fileName)))
{
if (deleteOld)
{
System.IO.File.Delete(FileIO.GetFilePath(folderName, fileName));
}
else
{
throw new ArgumentException("Cannot save. File allready exist");
}
}
// Open a filestream, and write the data from the client to it
FileStream objfilestream = new FileStream(FileIO.GetFilePath(folderName, fileName), FileMode.Create, FileAccess.ReadWrite);
objfilestream.Write(docbinaryarray, 0, docbinaryarray.Length);
objfilestream.Close();
}
else
{
throw new ArgumentException("no access to specified folder");
}
}
/// <summary>
/// To download a file, we need to know how big its going to be
/// </summary>
[WebMethod]
public int GetFileSize(String folderName, string fileName, string username, string password)
{
Authenticate(username, password);
// Check if folder is accessible
if (FileIO.FolderAccess(folderName))
{
// Check if the filename is valid
if (!FileIO.ValidFileName(fileName))
throw new ArgumentException(String.Format("Filename {0} not valid", fileName));
string strdocPath;
strdocPath = FileIO.GetFilePath(folderName, fileName);
// Load file into stream
FileStream objfilestream = new FileStream(strdocPath, FileMode.Open, FileAccess.Read);
// Find and return the lenght of the stream
int len = (int)objfilestream.Length;
objfilestream.Close();
return len;
}
else
{
throw new ArgumentException("no access to specified folder");
}
}
/// <summary>
/// Get all files in a specific folder
/// </summary>
/// <returns></returns>
[WebMethod]
public string[] GetFilesList(String folderName, string username, string password)
{
Authenticate(username, password);
if (FileIO.FolderAccess(folderName))
{
string fullPath = FileIO.GetFolderPath(folderName);
DirectoryInfo folder = new DirectoryInfo(fullPath);
FileInfo[] files = folder.GetFiles();
List<string> shortNames = new List<string>();
foreach (FileInfo file in files)
{
shortNames.Add(file.Name);
}
return shortNames.ToArray();
}
else
{
throw new ArgumentException("no access to specified folder");
}
}
}
}

View File

@@ -1,39 +0,0 @@
using System;
using System.ComponentModel;
using System.Web.Services;
namespace umbraco.webservices.maintenance
{
[WebService(Namespace = "http://umbraco.org/webservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class maintenanceService : BaseWebService
{
override public Services Service
{
get
{
return Services.MaintenanceService;
}
}
[WebMethod]
public string getWebservicesVersion(string username, string password)
{
// We check if services are enabled and user has access
Authenticate(username, password);
var thisVersion = new Version(0, 10);
return Convert.ToString(thisVersion);
}
[WebMethod]
public void restartApplication(string username, string password)
{
// We check if services are enabled and user has access
Authenticate(username, password);
System.Web.HttpRuntime.UnloadAppDomain();
}
}
}

View File

@@ -1,84 +0,0 @@
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
namespace umbraco.webservices.media
{
[Serializable]
[XmlType(Namespace = "http://umbraco.org/webservices/")]
public class mediaCarrier
{
public int Id
{
get;
set;
}
public string Text
{
get;
set;
}
public string TypeAlias
{
get;
set;
}
public int TypeId
{
get;
set;
}
public DateTime CreateDateTime
{
get;
set;
}
public Boolean HasChildren
{
get;
set;
}
public int Level
{
get;
set;
}
public int ParentId
{
get;
set;
}
public string Path
{
get;
set;
}
public int SortOrder
{
get;
set;
}
public List<mediaProperty> MediaProperties
{
get;
set;
}
public mediaCarrier()
{
MediaProperties = new List<mediaProperty>();
}
}
}

View File

@@ -1,24 +0,0 @@
using System.Xml.Serialization;
namespace umbraco.webservices.media
{
[XmlType(Namespace = "http://umbraco.org/webservices/")]
public class mediaProperty
{
public mediaProperty()
{
}
public object PropertyValue
{
get;
set;
}
public string Key
{
get;
set;
}
}
}

View File

@@ -1,296 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Web.Services;
using Umbraco.Core.Media;
using umbraco.cms.businesslogic.media;
using umbraco.cms.businesslogic.property;
using Umbraco.Core.IO;
using System.Xml;
using System.Text.RegularExpressions;
using System.Linq;
using System.Web.Script.Services;
using Umbraco.Core;
namespace umbraco.webservices.media
{
[WebService(Namespace = "http://umbraco.org/webservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
[ScriptService]
public class mediaService : BaseWebService
{
internal MediaFileSystem _fs;
public mediaService()
{
_fs = FileSystemProviderManager.Current.GetFileSystemProvider<MediaFileSystem>();
}
override public Services Service
{
get
{
return Services.MediaService;
}
}
[WebMethod]
public void update(mediaCarrier carrier, string username, string password)
{
Authenticate(username, password);
if (carrier == null) throw new Exception("No carrier specified");
var m = new Media(carrier.Id);
if (carrier.MediaProperties != null)
{
foreach (mediaProperty updatedproperty in carrier.MediaProperties)
{
if (!string.Equals(updatedproperty.Key, Constants.Conventions.Media.File, StringComparison.OrdinalIgnoreCase))
{
Property property = m.getProperty(updatedproperty.Key);
if (property == null)
throw new Exception("property " + updatedproperty.Key + " was not found");
property.Value = updatedproperty.PropertyValue;
}
}
}
m.Save();
}
[WebMethod]
public int create(mediaCarrier carrier, string username, string password)
{
Authenticate(username, password);
if (carrier == null) throw new Exception("No carrier specified");
if (carrier.ParentId == 0) throw new Exception("Media needs a parent");
if (carrier.TypeId == 0) throw new Exception("Type must be specified");
if (carrier.Text == null || carrier.Text.Length == 0) carrier.Text = "unnamed";
BusinessLogic.User user = GetUser(username, password);
var mt = new MediaType(carrier.TypeId);
var m = Media.MakeNew(carrier.Text, mt, user, carrier.ParentId);
if (carrier.MediaProperties != null)
{
foreach (mediaProperty updatedproperty in carrier.MediaProperties)
{
if (!string.Equals(updatedproperty.Key, Constants.Conventions.Media.File, StringComparison.OrdinalIgnoreCase))
{
Property property = m.getProperty(updatedproperty.Key);
if (property == null)
throw new Exception("property " + updatedproperty.Key + " was not found");
property.Value = updatedproperty.PropertyValue;
}
}
}
return m.Id;
}
[WebMethod]
public void delete(int id, string username, string password)
{
Authenticate(username, password);
Media m = new Media(id);
if (m.HasChildren)
throw new Exception("Cannot delete Media " + id + " as it has child nodes");
Property p = m.getProperty(Constants.Conventions.Media.File);
if (p != null)
{
if (!(p.Value == System.DBNull.Value))
{
var path = _fs.GetRelativePath(p.Value.ToString());
if(_fs.FileExists(path))
_fs.DeleteFile(path, true);
}
}
m.delete();
}
[WebMethod]
public void writeContents(int id, string filename, Byte[] contents, string username, string password)
{
Authenticate(username, password);
filename = filename.Replace("/", global::Umbraco.Core.IO.IOHelper.DirSepChar.ToString());
filename = filename.Replace(@"\", global::Umbraco.Core.IO.IOHelper.DirSepChar.ToString());
filename = filename.Substring(filename.LastIndexOf(global::Umbraco.Core.IO.IOHelper.DirSepChar) + 1, filename.Length - filename.LastIndexOf(global::Umbraco.Core.IO.IOHelper.DirSepChar) - 1).ToLower();
var m = new Media(id);
var numberedFolder = MediaSubfolderCounter.Current.Increment();
var path = _fs.GetRelativePath(numberedFolder.ToString(CultureInfo.InvariantCulture), filename);
var stream = new MemoryStream();
stream.Write(contents, 0, contents.Length);
stream.Seek(0, 0);
_fs.AddFile(path, stream);
m.getProperty(Constants.Conventions.Media.File).Value = _fs.GetUrl(path);
m.getProperty(Constants.Conventions.Media.Extension).Value = Path.GetExtension(filename).Substring(1);
m.getProperty(Constants.Conventions.Media.Bytes).Value = _fs.GetSize(path);
m.Save();
}
[WebMethod]
public mediaCarrier read(int id, string username, string password)
{
Authenticate(username, password);
Media m = new Media(id);
return createCarrier(m);
}
[WebMethod]
public List<mediaCarrier> readList(int parentId, string username, string password)
{
Authenticate(username, password);
var carriers = new List<mediaCarrier>();
Media[] mediaList;
if (parentId < 1)
{
mediaList = Media.GetRootMedias();
}
else
{
Media m = new Media(parentId);
mediaList = m.Children;
}
foreach (Media child in mediaList)
{
carriers.Add(createCarrier(child));
}
return carriers;
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public Result Embed(string url, int width, int height)
{
Result r = new Result();
//todo cache embed doc
var xmlConfig = new XmlDocument();
xmlConfig.Load(GlobalSettings.FullpathToRoot + Path.DirectorySeparatorChar + "config" + Path.DirectorySeparatorChar + "EmbeddedMedia.config");
foreach (XmlNode node in xmlConfig.SelectNodes("//provider"))
{
var regexPattern = new Regex(node.SelectSingleNode("./urlShemeRegex").InnerText, RegexOptions.IgnoreCase);
if (regexPattern.IsMatch(url))
{
var type = node.Attributes["type"].Value;
var prov = (IEmbedProvider)Activator.CreateInstance(Type.GetType(node.Attributes["type"].Value));
if (node.Attributes["supportsDimensions"] != null)
r.SupportsDimensions = node.Attributes["supportsDimensions"].Value == "True";
else
r.SupportsDimensions = prov.SupportsDimensions;
var settings = node.ChildNodes.Cast<XmlNode>().ToDictionary(settingNode => settingNode.Name);
foreach (var prop in prov.GetType().GetProperties().Where(prop => prop.IsDefined(typeof(ProviderSetting), true)))
{
if (settings.Any(s => s.Key.ToLower() == prop.Name.ToLower()))
{
XmlNode setting = settings.FirstOrDefault(s => s.Key.ToLower() == prop.Name.ToLower()).Value;
var settingType = typeof(Umbraco.Web.Media.EmbedProviders.Settings.String);
if (setting.Attributes["type"] != null)
settingType = Type.GetType(setting.Attributes["type"].Value);
var settingProv = (IEmbedSettingProvider)Activator.CreateInstance(settingType);
prop.SetValue(prov, settingProv.GetSetting(settings.FirstOrDefault(s => s.Key.ToLower() == prop.Name.ToLower()).Value), null);
}
}
try
{
r.Markup = prov.GetMarkup(url, width, height);
r.Status = Status.Success;
}
catch
{
r.Status = Status.Error;
}
return r;
}
}
r.Status = Status.NotSupported;
return r;
}
private mediaCarrier createCarrier(Media m)
{
var carrier = new mediaCarrier
{
Id = m.Id,
Text = m.Text,
TypeAlias = m.ContentType.Alias,
TypeId = m.ContentType.Id,
CreateDateTime = m.CreateDateTime,
HasChildren = m.HasChildren,
Level = m.Level,
Path = m.Path,
SortOrder = m.sortOrder
};
try
{
carrier.ParentId = m.Parent.Id;
}
catch
{
carrier.ParentId = -1;
}
foreach (Property p in m.GenericProperties)
{
var carrierprop = new mediaProperty();
if (p.Value == DBNull.Value)
{
carrierprop.PropertyValue = "";
}
else
{
carrierprop.PropertyValue = p.Value;
}
carrierprop.Key = p.PropertyType.Alias;
carrier.MediaProperties.Add(carrierprop);
}
return carrier;
}
}
}

View File

@@ -1,92 +0,0 @@
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
namespace umbraco.webservices.members
{
[Serializable]
[XmlType(Namespace = "http://umbraco.org/webservices/")]
public class memberCarrier
{
public memberCarrier()
{
memberProperties = new List<memberProperty>();
groups = new List<memberGroup>();
}
#region Fields
private int id;
private string password;
private string email;
private string displayedName;
private string loginName;
private int membertypeId;
private string membertypeName;
private List<memberGroup> groups;
private List<memberProperty> memberProperties;
#endregion
#region Properties
public int Id
{
get { return id; }
set { id = value; }
}
public string DisplayedName
{
get { return displayedName; }
set { displayedName = value; }
}
public string Password
{
get { return password; }
set { password = value; }
}
public string Email
{
get { return email; }
set { email = value; }
}
public string LoginName
{
get { return loginName; }
set { loginName = value; }
}
public int MembertypeId
{
get { return membertypeId; }
set { membertypeId = value; }
}
public string MembertypeName
{
get { return membertypeName; }
set { membertypeName = value; }
}
public List<memberGroup> Groups
{
get { return groups; }
set { groups = value; }
}
public List<memberProperty> MemberProperties
{
get { return memberProperties; }
set { memberProperties = value; }
}
#endregion
}
}

View File

@@ -1,34 +0,0 @@
using System;
namespace umbraco.webservices.members
{
[Serializable]
public class memberGroup
{
int groupID;
string groupName;
public memberGroup()
{
}
public memberGroup(int groupID, string groupName)
{
GroupID = groupID;
GroupName = groupName;
}
public int GroupID
{
get { return groupID; }
set { groupID = value; }
}
public string GroupName
{
get { return groupName; }
set { groupName = value; }
}
}
}

View File

@@ -1,29 +0,0 @@
using System;
using System.Xml.Serialization;
namespace umbraco.webservices.members
{
[Serializable]
[XmlType(Namespace = "http://umbraco.org/webservices/")]
public class memberProperty
{
private string key;
private object propertyValue;
public memberProperty()
{
}
public object PropertyValue
{
get { return propertyValue; }
set { propertyValue = value; }
}
public string Key
{
get { return key; }
set { key = value; }
}
}
}

View File

@@ -1,240 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Web.Services;
using umbraco.cms.businesslogic.member;
namespace umbraco.webservices.members
{
[WebService(Namespace = "http://umbraco.org/webservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class memberService : BaseWebService
{
override public Services Service
{
get
{
return Services.MemberService;
}
}
/// <summary>
/// Reads the user with the specified memberId
/// </summary>
/// <returns></returns>
[WebMethod]
public memberCarrier readByLogin(string memberLoginName, string memberPassword, string username, string password)
{
Authenticate(username, password);
umbraco.cms.businesslogic.member.Member foundMember = umbraco.cms.businesslogic.member.Member.GetMemberFromLoginNameAndPassword(memberLoginName, memberPassword);
if (foundMember == null)
return null;
return CreateMemberCarrier(foundMember);
}
/// <summary>
/// Reads the user with the specified memberId
/// </summary>
/// <returns></returns>
[WebMethod]
public memberCarrier readById(int memberId, string username, string password)
{
Authenticate(username, password);
umbraco.cms.businesslogic.member.Member foundMember = new umbraco.cms.businesslogic.member.Member(memberId);
if (foundMember == null)
return null;
return CreateMemberCarrier(foundMember);
}
/// <summary>
/// Reads the full list of members
/// </summary>
/// <returns></returns>
[WebMethod]
public List<memberCarrier> readList(string username, string password)
{
Authenticate(username, password);
Member[] members = Member.GetAll;
List<memberCarrier> Members = new List<memberCarrier>();
foreach (umbraco.cms.businesslogic.member.Member member in members)
{
Members.Add(CreateMemberCarrier(member));
}
return Members;
}
[WebMethod]
public void update(memberCarrier carrier, string username, string password)
{
Authenticate(username, password);
// Some validation
if (carrier.Id == 0) throw new Exception("ID must be specifed when updating");
if (carrier == null) throw new Exception("No carrier specified");
// Get the user
umbraco.BusinessLogic.User user = GetUser(username, password);
// We load the member
Member member = new Member(carrier.Id);
// We assign the new values:
member.LoginName = carrier.LoginName;
member.Text = carrier.DisplayedName;
member.Email = carrier.Email;
member.Password = carrier.Password;
// We iterate the properties in the carrier
if (carrier.MemberProperties != null)
{
foreach (memberProperty updatedproperty in carrier.MemberProperties)
{
umbraco.cms.businesslogic.property.Property property = member.getProperty(updatedproperty.Key);
if (property != null)
{
property.Value = updatedproperty.PropertyValue;
}
}
}
}
[WebMethod]
public int create(memberCarrier carrier, int memberTypeId, string username, string password)
{
Authenticate(username, password);
// Some validation
if (carrier == null) throw new Exception("No carrier specified");
if (carrier.Id != 0) throw new Exception("ID cannot be specifed when creating. Must be 0");
if (string.IsNullOrEmpty(carrier.DisplayedName)) carrier.DisplayedName = "unnamed";
// we fetch the membertype
umbraco.cms.businesslogic.member.MemberType mtype = new umbraco.cms.businesslogic.member.MemberType(memberTypeId);
// Check if the membertype exists
if (mtype == null) throw new Exception("Membertype " + memberTypeId + " not found");
// Get the user that creates
umbraco.BusinessLogic.User user = GetUser(username, password);
// Create the new member
umbraco.cms.businesslogic.member.Member newMember = umbraco.cms.businesslogic.member.Member.MakeNew(carrier.DisplayedName, mtype, user);
// We iterate the properties in the carrier
if (carrier.MemberProperties != null)
{
foreach (memberProperty updatedproperty in carrier.MemberProperties)
{
umbraco.cms.businesslogic.property.Property property = newMember.getProperty(updatedproperty.Key);
if (property != null)
{
property.Value = updatedproperty.PropertyValue;
}
}
}
return newMember.Id;
}
/// <summary>
/// Deletes the document with the specified ID
/// </summary>
/// <param name="id"></param>
/// <param name="cred"></param>
/// <returns></returns>
[WebMethod]
public void delete(int id, string username, string password)
{
Authenticate(username, password);
// We load the member
umbraco.cms.businesslogic.member.Member deleteMember;
try
{
deleteMember = new umbraco.cms.businesslogic.member.Member(id);
}
catch (Exception ex)
{
throw new Exception("Member not found" + ex.Message);
}
// We delete him (cruel world)
try
{
deleteMember.delete();
}
catch (Exception ex)
{
throw new Exception("Member could not be deleted" + ex.Message);
}
}
/// <summary>
/// Creates container-object for member
/// </summary>
/// <param name="member"></param>
/// <returns></returns>
private memberCarrier CreateMemberCarrier(umbraco.cms.businesslogic.member.Member member)
{
memberCarrier carrier = new memberCarrier();
carrier.Id = member.Id;
carrier.LoginName = member.LoginName;
carrier.DisplayedName = member.Text;
carrier.Email = member.Email;
carrier.Password = member.Password;
carrier.MembertypeId = member.ContentType.Id;
carrier.MembertypeName = member.ContentType.Text;
// Adding groups to member-carrier
IDictionaryEnumerator Enumerator;
Enumerator = member.Groups.GetEnumerator();
while (Enumerator.MoveNext())
{
memberGroup group = new memberGroup(Convert.ToInt32(Enumerator.Key), ((umbraco.cms.businesslogic.member.MemberGroup)Enumerator.Value).Text);
carrier.Groups.Add(group);
}
// Loading properties to carrier
var props = member.GenericProperties;
foreach (umbraco.cms.businesslogic.property.Property prop in props)
{
memberProperty carrierprop = new memberProperty();
if (prop.Value == System.DBNull.Value)
{
carrierprop.PropertyValue = null;
}
else
{
carrierprop.PropertyValue = prop.Value;
}
carrierprop.Key = prop.PropertyType.Alias;
carrier.MemberProperties.Add(carrierprop);
}
return carrier;
}
}
}

View File

@@ -1,137 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Web.Services;
using umbraco.cms.businesslogic.web;
namespace umbraco.webservices.stylesheets
{
/// <summary>
/// Summary description for StylesheetService
/// </summary>
[WebService(Namespace = "http://umbraco.org/webservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class stylesheetService : BaseWebService
{
override public Services Service
{
get
{
return Services.StylesheetService;
}
}
[WebMethod]
public int create(stylesheetCarrier carrier, string username, string password)
{
Authenticate(username, password);
umbraco.BusinessLogic.User user = GetUser(username, password);
StyleSheet stylesheet = StyleSheet.MakeNew(user, carrier.Name, (carrier.Name + ".css"), carrier.Content);
stylesheet.saveCssToFile();
return stylesheet.Id;
}
[WebMethod]
public stylesheetCarrier read(int id, string username, string password)
{
Authenticate(username, password);
StyleSheet stylesheet;
try
{
stylesheet = new StyleSheet(id);
}
catch (Exception)
{
throw new Exception("Could not load stylesheet with id: " + id + ", not found");
}
if (stylesheet == null)
throw new Exception("Could not load stylesheet with id: " + id + ", not found");
return createCarrier(stylesheet);
}
[WebMethod]
public List<stylesheetCarrier> readList(string username, string password)
{
Authenticate(username, password);
List<stylesheetCarrier> stylesheets = new List<stylesheetCarrier>();
StyleSheet[] foundstylesheets = StyleSheet.GetAll();
foreach (StyleSheet stylesheet in foundstylesheets)
{
stylesheets.Add(createCarrier(stylesheet));
}
return stylesheets;
}
[WebMethod]
public void update(stylesheetCarrier carrier, string username, string password)
{
Authenticate(username, password);
StyleSheet stylesheet = null;
try
{
stylesheet = new StyleSheet(carrier.Id);
}
catch
{ }
if (stylesheet == null)
throw new Exception("Could not load stylesheet with id: " + carrier.Id);
stylesheet.Content = carrier.Content;
stylesheet.saveCssToFile();
}
private stylesheetCarrier createCarrier(StyleSheet stylesheet)
{
stylesheetCarrier carrier = new stylesheetCarrier();
carrier.Id = stylesheet.Id;
carrier.Name = stylesheet.Text;
carrier.Content = stylesheet.Content;
return carrier;
}
public class stylesheetCarrier
{
private int id;
private string name;
private string content;
public int Id
{
get { return id; }
set { id = value; }
}
public string Name
{
get { return name; }
set { name = value; }
}
public string Content
{
get { return content; }
set { content = value; }
}
}
}
}

View File

@@ -1,179 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web.Services;
using Umbraco.Core;
using Umbraco.Web;
using Umbraco.Web.Cache;
namespace umbraco.webservices.templates
{
/// <summary>
/// Summary description for TemplateService
/// </summary>
[WebService(Namespace = "http://umbraco.org/webservices/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class templateService : BaseWebService
{
override public Services Service
{
get
{
return Services.TemplateService;
}
}
[WebMethod]
public int readIdFromAlias(string alias, string username, string password)
{
Authenticate(username, password);
cms.businesslogic.template.Template template;
try
{
template = cms.businesslogic.template.Template.GetByAlias(alias, true);
}
catch (Exception)
{
throw new Exception("Could not load template from alias: " + alias);
}
if (template == null)
{
throw new Exception("Could not load template from alias: " + alias);
}
return template.Id;
}
[WebMethod]
public List<templateCarrier> readList(string username, string password)
{
Authenticate(username, password);
var templateCarriers = new List<templateCarrier>();
foreach (var template in cms.businesslogic.template.Template.GetAllAsList())
{
templateCarriers.Add(createTemplateCarrier(template));
}
return templateCarriers;
}
[WebMethod]
public void delete(int id, string username, string password)
{
Authenticate(username, password);
if (id == 0)
throw new Exception("ID must be specifed when updating");
var template = new cms.businesslogic.template.Template(id);
template.delete();
}
[WebMethod]
public int create(templateCarrier carrier, string username, string password)
{
Authenticate(username, password);
if (carrier.Id != 0) throw new Exception("ID may not be specified when creating");
if (carrier == null) throw new Exception("No carrier specified");
// Get the user
BusinessLogic.User user = GetUser(username, password);
// Create template
var template = cms.businesslogic.template.Template.MakeNew(carrier.Name, user);
template.MasterTemplate = carrier.MastertemplateId;
template.Alias = carrier.Alias;
template.Text = carrier.Name;
template.Design = carrier.Design;
template.Save();
return template.Id;
}
[WebMethod]
public void update(templateCarrier carrier, string username, string password)
{
Authenticate(username, password);
if (carrier.Id == 0) throw new Exception("ID must be specifed when updating");
if (carrier == null) throw new Exception("No carrier specified");
cms.businesslogic.template.Template template;
try
{
template = new cms.businesslogic.template.Template(carrier.Id);
}
catch (Exception)
{
throw new Exception("Template with ID " + carrier.Id + " not found");
}
template.MasterTemplate = carrier.MastertemplateId;
template.Alias = carrier.Alias;
template.Text = carrier.Name;
template.Design = carrier.Design;
template.Save();
}
[WebMethod]
public templateCarrier read(int id, string username, string password)
{
Authenticate(username, password);
cms.businesslogic.template.Template template;
try
{
template = new cms.businesslogic.template.Template(id);
}
catch (Exception)
{
throw new Exception("Template with ID " + id + " not found");
}
if (template == null)
throw new Exception("Template with ID " + id + " not found");
return createTemplateCarrier(template);
}
public templateCarrier createTemplateCarrier(cms.businesslogic.template.Template template)
{
var carrier = new templateCarrier
{
Id = template.Id,
MastertemplateId = template.MasterTemplate,
Alias = template.Alias,
Name = template.Text,
Design = template.Design,
MasterPageFile = template.MasterPageFile
};
return carrier;
}
public class templateCarrier
{
public int Id { get; set; }
public int MastertemplateId { get; set; }
public string MasterPageFile { get; set; }
public string Name { get; set; }
public string Alias { get; set; }
public string Design { get; set; }
}
}
}

View File

@@ -1,196 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CBDB56AC-FF02-4421-9FD4-ED82E339D8E2}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>umbraco.webservices</RootNamespace>
<AssemblyName>umbraco.webservices</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>
</SccProjectName>
<SccLocalPath>
</SccLocalPath>
<SccAuxPath>
</SccAuxPath>
<SccProvider>
</SccProvider>
<FileUpgradeFlags>
</FileUpgradeFlags>
<OldToolsVersion>3.5</OldToolsVersion>
<UpgradeBackupLocation />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<DocumentationFile>bin\Release\umbraco.webservices.xml</DocumentationFile>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Web" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.Helpers.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.Mvc.4.0.20710.0\lib\net40\System.Web.Mvc.dll</HintPath>
</Reference>
<Reference Include="System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.Razor.2.0.20715.0\lib\net40\System.Web.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Web.Services" />
<Reference Include="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Deployment.dll</HintPath>
</Reference>
<Reference Include="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Razor.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\SolutionInfo.cs">
<Link>Properties\SolutionInfo.cs</Link>
</Compile>
<Compile Include="BaseWebService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Common.cs" />
<Compile Include="documents\documentCarrier.cs" />
<Compile Include="documents\documentProperty.cs" />
<Compile Include="files\fileService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="maintenance\maintenanceService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="media\mediaCarrier.cs" />
<Compile Include="media\mediaProperty.cs" />
<Compile Include="media\mediaService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="members\memberCarrier.cs" />
<Compile Include="members\memberGroup.cs" />
<Compile Include="members\memberProperty.cs" />
<Compile Include="members\memberService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="stylesheets\stylesheetService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="templates\templateService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="documents\documentService.cs">
<SubType>Component</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\umbraco.businesslogic\umbraco.businesslogic.csproj">
<Project>{E469A9CE-1BEC-423F-AC44-713CD72457EA}</Project>
<Name>umbraco.businesslogic</Name>
</ProjectReference>
<ProjectReference Include="..\umbraco.cms\umbraco.cms.csproj">
<Project>{CCD75EC3-63DB-4184-B49D-51C1DD337230}</Project>
<Name>umbraco.cms</Name>
</ProjectReference>
<ProjectReference Include="..\Umbraco.Core\Umbraco.Core.csproj">
<Project>{31785BC3-256C-4613-B2F5-A1B0BDDED8C1}</Project>
<Name>Umbraco.Core</Name>
</ProjectReference>
<ProjectReference Include="..\Umbraco.Web\Umbraco.Web.csproj">
<Project>{651E1350-91B6-44B7-BD60-7207006D7003}</Project>
<Name>Umbraco.Web</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
</Project>