Exemplo n.º 1
0
        /// <summary>
        /// Deletes a media resource using the information present in the HttpContext.
        /// </summary>
        /// <param name="context">The HttpContext for the incoming HTTP request.</param>
        /// <returns>True if the operation succeeds, False otherwise.</returns>
        private bool DeleteMedia(HttpContext context)
        {
            // Gets the atom request template match result to get requested collection name.
            string collectionName = AtomPubHelper.GetValueOfParameterFromUri(context, base.BaseUri, AtomPubParameterType.CollectionName);
            string memberId       = AtomPubHelper.GetValueOfParameterFromUri(context, base.BaseUri, AtomPubParameterType.Id);

            IAtomPubStoreWriter atomPubStoreWriter = AtomPubStoreFactory.GetAtomPubStoreWriter(base.BaseUri.OriginalString);

            return(atomPubStoreWriter.DeleteMedia(collectionName, memberId));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a member resource using the information present in the HttpContext.
        /// </summary>
        /// <param name="context">The HttpContext for the incoming HTTP request.</param>
        /// <returns>An AtomEntryDocument corresponding to the newly created member resource.</returns>
        private AtomEntryDocument CreateMember(HttpContext context)
        {
            string collectionName = AtomPubHelper.GetValueOfParameterFromUri(context, base.BaseUri,
                                                                             AtomPubParameterType.CollectionName);

            //Get AtomEntryDocument for request to update the member information.
            AtomEntryDocument atomEntry = new AtomEntryDocument(context.Request.InputStream);

            IAtomPubStoreWriter atomPubStoreWriter = AtomPubStoreFactory.GetAtomPubStoreWriter(base.BaseUri.OriginalString);
            SyndicationItem     item = atomPubStoreWriter.CreateMember(collectionName, atomEntry);

            // Create atom entry document from syndication item.
            return(new AtomEntryDocument(item));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Updates a member resource using the information present in the HttpContext.
        /// </summary>
        /// <param name="context">The HttpContext for the incoming HTTP request.</param>
        /// <returns>An AtomEntryDocument corresponding to the updated member resource.</returns>
        private AtomEntryDocument UpdateMember(HttpContext context)
        {
            // Gets the atom request template match result to get requested collection name.
            string collectionName = AtomPubHelper.GetValueOfParameterFromUri(context, base.BaseUri, AtomPubParameterType.CollectionName);
            string memberId       = AtomPubHelper.GetValueOfParameterFromUri(context, base.BaseUri, AtomPubParameterType.Id);

            IAtomPubStoreWriter atomPubStoreWriter = AtomPubStoreFactory.GetAtomPubStoreWriter(base.BaseUri.OriginalString);

            //Get AtomEntryDocument for request to update the member information.
            AtomEntryDocument atomDocument = new AtomEntryDocument(context.Request.InputStream);

            SyndicationItem item = atomPubStoreWriter.UpdateMemberInfo(collectionName, memberId, atomDocument);

            // Get AtomEntryDocument for response.
            return(new AtomEntryDocument(item));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Updates a media resource using the information present in the HttpContext.
        /// </summary>
        /// <param name="context">The HttpContext for the incoming HTTP request.</param>
        /// <returns>An AtomEntryDocument corresponding to the updated media resource.</returns>
        private AtomEntryDocument UpdateMedia(HttpContext context)
        {
            // Gets the atom request template match result to get requested collection name.
            string collectionName = AtomPubHelper.GetValueOfParameterFromUri(context, base.BaseUri, AtomPubParameterType.CollectionName);
            string memberId       = AtomPubHelper.GetValueOfParameterFromUri(context, base.BaseUri, AtomPubParameterType.Id);

            IAtomPubStoreWriter atomPubStoreWriter = AtomPubStoreFactory.GetAtomPubStoreWriter(base.BaseUri.OriginalString);

            // Get byte array to update media.
            BinaryReader reader = new BinaryReader(context.Request.InputStream);

            byte[] media = new byte[context.Request.InputStream.Length];
            reader.Read(media, 0, media.Length);

            SyndicationItem item = atomPubStoreWriter.UpdateMedia(collectionName, memberId, context.Request.ContentType, media);

            // Get AtomEntryDocument for response.
            return(new AtomEntryDocument(item));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a media resource using the information present in the HttpContext.
        /// </summary>
        /// <param name="context">The HttpContext for the incoming HTTP request.</param>
        /// <returns>An AtomEntryDocument corresponding to the newly created media resource.</returns>
        private AtomEntryDocument CreateMedia(HttpContext context)
        {
            SyndicationItem item = null;

            string collectionName = AtomPubHelper.GetValueOfParameterFromUri(context,
                                                                             base.BaseUri,
                                                                             AtomPubParameterType.CollectionName);

            // Get byte array to update media.
            BinaryReader reader = new BinaryReader(context.Request.InputStream);

            byte[] media = new byte[context.Request.InputStream.Length];
            reader.Read(media, 0, media.Length);

            string fileExtention = string.Empty;

            if (context.Request.Headers.AllKeys.Contains("Content-Disposition"))
            {
                fileExtention = AtomPubHelper.GetFileExtentionFromContentDisposition(
                    context.Request.Headers["Content-Disposition"]);
            }

            IAtomPubStoreWriter swordStoreWriter = AtomPubStoreFactory.GetSwordStoreWriter();

            item = swordStoreWriter.CreateMedia(collectionName, context.Request.ContentType, media, fileExtention);

            AtomEntryDocument atomEntryDocument = null;

            if (null != item)
            {
                // Add <sword:treatment>Successfully created a {Collection Name}</sword:treatment> element.
                SwordPostProcessor.AddTreatmentElement(collectionName, item);

                // Create atom entry document from syndication item.
                atomEntryDocument = new AtomEntryDocument(item);
            }

            return(atomEntryDocument);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a media resource using the information present in the HttpContext.
        /// </summary>
        /// <param name="context">The HttpContext for the incoming HTTP request.</param>
        /// <returns>An AtomEntryDocument corresponding to the newly created media resource.</returns>
        private AtomEntryDocument CreateMedia(HttpContext context)
        {
            string collectionName = AtomPubHelper.GetValueOfParameterFromUri(context, base.BaseUri,
                                                                             AtomPubParameterType.CollectionName);

            string fileExtention = string.Empty;

            if (context.Request.Headers.AllKeys.Contains("Content-Disposition"))
            {
                fileExtention = AtomPubHelper.GetFileExtentionFromContentDisposition(
                    context.Request.Headers["Content-Disposition"]);
            }
            // Get byte array to update media.
            BinaryReader reader = new BinaryReader(context.Request.InputStream);

            byte[] media = new byte[context.Request.InputStream.Length];
            reader.Read(media, 0, media.Length);

            IAtomPubStoreWriter atomPubStoreWriter = AtomPubStoreFactory.GetAtomPubStoreWriter(base.BaseUri.OriginalString);
            SyndicationItem     item = atomPubStoreWriter.CreateMedia(collectionName, context.Request.ContentType, media, fileExtention);

            // Create atom entry document from syndication item.
            return(new AtomEntryDocument(item));
        }