DavPutBase.cs :  » Network-Servers » WebDAV.NET-Server » Sphorium » WebDAV » Server » Framework » BaseClasses » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Network Servers » WebDAV.NET Server 
WebDAV.NET Server » Sphorium » WebDAV » Server » Framework » BaseClasses » DavPutBase.cs
using System;
using System.IO;

namespace Sphorium.WebDAV.Server.Framework.BaseClasses{
  /// <summary>
  /// Dav Resource Put Framework Base Class
  /// </summary>
  /// <remarks>
  ///    RFC2518 Compliant
  ///    
  ///    <code>
  ///    The ProcessDavRequest event must follow the following rules addressed in RFC2518
  ///      http://www.webdav.org/specs/rfc2518.html#METHOD_PUT
  ///      
  ///    - A PUT that would result in the creation of a resource without an appropriately 
  ///      scoped parent collection
  ///      
  ///        For example, if resource /a/b/c/d.html is to be created and /a/b/c/ does not exist
  ///        
  ///      MUST fail with:
  ///      
  ///          base.AbortRequest(DavPutResponseCode.Conflict)
  ///    </code>
  ///    
  ///    <code>
  ///      Returns DavPutResponseCode.Created when successful
  ///    </code>
  ///    <seealso cref="DavPutResponseCode"/>
  ///    <seealso cref="DavMethodBase.AbortRequest(System.Enum)"/>
  /// </remarks>    
  public abstract class DavPutBase : DavMethodBase
  {
    /// <summary>
    /// Dav Resource Put Framework Base Class
    /// </summary>
    protected DavPutBase()
    {
      this.ValidateDavRequest += new DavRequestValidator(DavPutBase_ValidateDavRequest);
      this.InternalProcessDavRequest += new DavInternalProcessHandler(DavPutBase_InternalProcessDavRequest);
    }

    /// <summary>
    /// WebDav PUT Response Codes
    /// </summary>
    protected enum DavPutResponseCode : int
    {
      /// <summary>
      /// 0: None
      /// </summary>
      /// <remarks>
      ///    Default enumerator value
      /// </remarks>
      None = 0,

      /// <summary>
      /// 201: Created
      /// </summary>
      /// <remarks>
      ///    Resource completed successfully
      /// </remarks>
      Created = 201,

      /// <summary>
      /// 403: Forbidden
      /// </summary>
      /// <remarks>
      ///    This indicates one of two conditions: 
      ///      - The server does not allow the creation of the resource at the given 
      ///        location in its namespace
      ///      - The parent collection of the Request-URI exists but cannot accept members.
      /// </remarks>
      Forbidden = 403,

      /// <summary>
      /// 409: Conflict
      /// </summary>
      /// <remarks>
      ///    If all ancestor collections do not exist
      /// </remarks>
      Conflict = 409,

      /// <summary>
      /// 423: Resource Locked
      /// </summary>
      /// <remarks>
      ///    If the resource is already locked with an exclusive lock or if the resource
      ///    is already locked with a shared lock and the client requests and exclusive lock
      /// </remarks>
      Locked = 423,

      /// <remarks>
      ///    The resource does not have sufficient space to record the state of the 
      ///    resource after the execution of this method.
      /// </remarks>
      InsufficientStorage = 507
    }

    /// <summary>
    /// Request content type
    /// </summary>
    protected string ContentType
    {
      get
      {
        return base.HttpApplication.Request.ContentType;
      }
    }

    /// <summary>
    /// Check to see if an existing resource should be overwritten
    /// </summary>
    protected bool OverwriteExistingResource
    {
      get
      {
        if (base.HttpApplication.Request.Headers["If-None-Match"] != null)
          return false;

        return true;
      }
    }

    /// <summary>
    /// Request input 
    /// </summary>
    protected byte[] GetRequestInput()
    {
      StreamReader _inputStream = new StreamReader(base.HttpApplication.Request.InputStream);

      long _inputSize = _inputStream.BaseStream.Length;

      byte[] _inputBytes = new byte[_inputSize];
      _inputStream.BaseStream.Read(_inputBytes, 0, (int)_inputSize);
      return _inputBytes;
    }

    private int DavPutBase_ValidateDavRequest(object sender, EventArgs e)
    {
      //if (base.RequestLength == 0)
      //  return (int)ServerResponseCode.BadRequest;

      return (int)ServerResponseCode.Ok;
    }

    private int DavPutBase_InternalProcessDavRequest(object sender, EventArgs e)
    {
      //return (int)DavPutResponseCode.Created;
      return (int)ServerResponseCode.Ok;
    }
  }
}
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.