Example #1
0
        public static SharepointObject Read(SharepointSession session, ObjectId id)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            SharepointSiteId sharepointSiteId = id as SharepointSiteId;

            if (sharepointSiteId == null)
            {
                throw new ArgumentException("id");
            }
            if (sharepointSiteId is SharepointDocumentLibraryItemId)
            {
                return(SharepointDocumentLibraryItem.Read(session, sharepointSiteId));
            }
            if (sharepointSiteId is SharepointListId)
            {
                return(SharepointList.Read(session, sharepointSiteId));
            }
            throw new ObjectNotFoundException(sharepointSiteId, Strings.ExObjectNotFound(sharepointSiteId.ToString()));
        }
Example #2
0
        public new static SharepointDocumentLibraryItem Read(SharepointSession session, ObjectId objectId)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (objectId == null)
            {
                throw new ArgumentNullException("objectId");
            }
            SharepointDocumentLibraryItemId itemId = objectId as SharepointDocumentLibraryItemId;

            if (itemId == null)
            {
                throw new ArgumentException("objectId");
            }
            if (itemId.UriFlags != UriFlags.SharepointDocument && itemId.UriFlags != UriFlags.SharepointFolder)
            {
                throw new ArgumentException("objectId");
            }
            if (session.Uri != itemId.SiteUri)
            {
                throw new ObjectNotFoundException(itemId, Strings.ExObjectMovedOrDeleted(itemId.ToString()));
            }
            if (itemId.Cache != null && itemId.Cache.Value.Key == session.Identity.Name)
            {
                if (itemId.UriFlags == UriFlags.SharepointFolder)
                {
                    return(new SharepointDocumentLibraryFolder(itemId, session, itemId.Cache.Value.Value));
                }
                if (itemId.UriFlags == UriFlags.SharepointDocument)
                {
                    return(new SharepointDocument(itemId, session, itemId.Cache.Value.Value));
                }
            }
            return(Utils.DoSharepointTask <SharepointDocumentLibraryItem>(session.Identity, itemId, itemId, false, Utils.MethodType.Read, delegate
            {
                XmlNode nodeForItem = SharepointDocumentLibraryItem.GetNodeForItem(session, itemId);
                if (nodeForItem != null)
                {
                    SharepointList sharepointList = SharepointList.Read(session, new SharepointListId(itemId.ListName, itemId.SiteUri, null, UriFlags.SharepointDocumentLibrary));
                    itemId.Cache = new KeyValuePair <string, XmlNode>?(new KeyValuePair <string, XmlNode>(session.Identity.Name, nodeForItem));
                    itemId.CultureInfo = sharepointList.GetRegionalSettings();
                    if (itemId.UriFlags == UriFlags.SharepointFolder)
                    {
                        return new SharepointDocumentLibraryFolder(itemId, session, itemId.Cache.Value.Value);
                    }
                    if (itemId.UriFlags == UriFlags.SharepointDocument)
                    {
                        return new SharepointDocument(itemId, session, itemId.Cache.Value.Value);
                    }
                }
                throw new ObjectNotFoundException(itemId, Strings.ExObjectNotFound(itemId.ToString()));
            }));
        }
        public SharepointDocumentLibraryItem Read(ObjectId objectId, params PropertyDefinition[] propsToReturn)
        {
            if (objectId == null)
            {
                throw new ArgumentNullException("objectId");
            }
            SharepointItemId sharepointItemId = objectId as SharepointItemId;
            SharepointListId sharepointListId = base.Id as SharepointListId;

            if (sharepointItemId == null)
            {
                throw new ArgumentException("objectId as SharepointItemId");
            }
            if (sharepointItemId.ListName != sharepointListId.ListName || sharepointItemId.SiteUri != sharepointListId.SiteUri)
            {
                throw new ObjectNotFoundException(objectId, Strings.ExObjectNotFound(objectId.ToString()));
            }
            return(SharepointDocumentLibraryItem.Read(this.Session, objectId));
        }
Example #4
0
        public new static SharepointDocumentLibraryFolder Read(SharepointSession session, ObjectId objectId)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (objectId == null)
            {
                throw new ArgumentNullException("objectId");
            }
            SharepointDocumentLibraryItemId sharepointDocumentLibraryItemId = objectId as SharepointDocumentLibraryItemId;

            if (sharepointDocumentLibraryItemId == null)
            {
                throw new ArgumentException("objectId");
            }
            if (sharepointDocumentLibraryItemId.UriFlags != UriFlags.SharepointFolder)
            {
                throw new ArgumentException("objectId");
            }
            return((SharepointDocumentLibraryFolder)SharepointDocumentLibraryItem.Read(session, objectId));
        }
Example #5
0
        public new static SharepointDocument Read(SharepointSession session, ObjectId id)
        {
            if (session == null)
            {
                throw new ArgumentNullException("session");
            }
            if (id == null)
            {
                throw new ArgumentNullException("id");
            }
            SharepointDocumentLibraryItemId sharepointDocumentLibraryItemId = id as SharepointDocumentLibraryItemId;

            if (sharepointDocumentLibraryItemId == null)
            {
                throw new ArgumentException("id");
            }
            if (sharepointDocumentLibraryItemId.UriFlags != UriFlags.SharepointDocument)
            {
                throw new ArgumentException("id");
            }
            return((SharepointDocument)SharepointDocumentLibraryItem.Read(session, id));
        }
Example #6
0
 public Stream GetDocument()
 {
     return(Utils.DoSharepointTask <Stream>(this.Session.Identity, base.Id, (SharepointSiteId)base.Id, true, Utils.MethodType.GetStream, delegate
     {
         Stream stream = null;
         HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(this.Uri);
         httpWebRequest.KeepAlive = false;
         httpWebRequest.Headers.Set("Pragma", "no-cache");
         httpWebRequest.Headers.Set("Depth", "0");
         httpWebRequest.ContentType = "text/xml";
         httpWebRequest.ContentLength = 0L;
         httpWebRequest.Credentials = CredentialCache.DefaultCredentials;
         HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
         stream = httpWebResponse.GetResponseStream();
         bool flag = false;
         try
         {
             SharepointDocumentLibraryItemId sharepointDocumentLibraryItemId = (SharepointDocumentLibraryItemId)base.Id;
             XmlNode nodeForItem = SharepointDocumentLibraryItem.GetNodeForItem(this.Session, sharepointDocumentLibraryItemId);
             SharepointDocument sharepointDocument = new SharepointDocument(sharepointDocumentLibraryItemId, this.Session, nodeForItem);
             if (sharepointDocument.VersionControl.TipVersion != this.VersionControl.TipVersion)
             {
                 throw new DocumentModifiedException(base.Id, this.Uri.ToString());
             }
             flag = true;
         }
         finally
         {
             if (!flag)
             {
                 stream.Dispose();
                 stream = null;
             }
         }
         return stream;
     }));
 }