Exemple #1
0
        public bool CheckOutFile(string pageUrl, string checkoutToLocal, string lastmodified)
        {
            //<pageUrl>http://snbppc070/Root/Sites/Default_Site/workspaces/Document/losangelesdocumentworkspace/Document_Library/Duis%20et%20lorem.doc</pageUrl>
            //<checkoutToLocal>true</checkoutToLocal>
            //<lastmodified>3/25/2011 3:25:14 PM</lastmodified></CheckOutFile>

            if (DwsHelper.CheckVisitor())
            {
                return(false);
            }

            var path = DwsHelper.GetPathFromUrl(pageUrl);
            var node = Node.LoadNode(path);

            if (node != null)
            {
                if (!node.Lock.Locked)
                {
                    try
                    {
                        var gc = node as GenericContent;
                        gc.CheckOut();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteException(ex);
                    }
                }
            }

            return(false);
        }
Exemple #2
0
        public bool UndoCheckOut(string pageUrl)
        {
            if (DwsHelper.CheckVisitor())
            {
                return(false);
            }

            var path = DwsHelper.GetPathFromUrl(pageUrl);
            var node = Node.LoadNode(path);

            if (node != null)
            {
                if (node.Lock.Locked && node.LockedById == ContentRepository.User.Current.Id)
                {
                    try
                    {
                        var gc = node as GenericContent;
                        gc.UndoCheckOut();
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteException(ex);
                    }
                }
            }
            return(false);
        }
Exemple #3
0
        public VersionOperationResult GetVersions(string fileName)
        {
            if (DwsHelper.CheckVisitor())
            {
                return(null);
            }

            var url  = this.RequestUrl + "/" + fileName;
            var path = RepositoryPath.Combine(this.RequestPath, fileName);
            var file = Node.Load <GenericContent>(path);

            if (file == null)
            {
                return(null);
            }
            var list = file.ContentListId;

            VersionOperationResult vr = new VersionOperationResult();

            vr.results                    = new VersionResults();
            vr.results.list               = new VersionResultsList();
            vr.results.list.id            = list == 0 ? string.Empty : list.ToString();
            vr.results.settings           = new VersionResultsSettings();
            vr.results.settings.url       = url;
            vr.results.versioning         = new VersionResultsVersioning();
            vr.results.versioning.enabled = file.VersioningMode > VersioningType.None ? (byte)1 : (byte)0;

            List <VersionData> versionData = new List <VersionData>();

            foreach (var version in file.Versions)
            {
                var createdBy   = version.CreatedBy as User;
                var fileVersion = version as File;

                VersionData vd = new VersionData();
                vd.version       = String.Format("{0}{1}.{2}", file.Version == version.Version ? "@" : String.Empty, version.Version.Major, version.Version.Minor);
                vd.url           = url + "?version=" + version.Version;
                vd.created       = version.CreationDate.ToString();
                vd.createdRaw    = version.CreationDate.ToString("yyyy-MM-ddThh:mm:ssZ");
                vd.createdBy     = createdBy == null ? string.Empty : createdBy.Username;
                vd.createdByName = createdBy == null ? string.Empty : createdBy.DisplayName;
                vd.size          = fileVersion == null ? (ulong)0 : (ulong)fileVersion.Size;
                vd.comments      = version.GetProperty <string>("CheckInComments") ?? string.Empty;

                versionData.Add(vd);
            }

            vr.results.result = versionData.ToArray();

            return(vr);
        }
Exemple #4
0
        public bool CheckInFile(string pageUrl, string comment, string CheckinType)
        {
            //<pageUrl>http://snbppc070/Root/Sites/Default_Site/workspaces/Document/romedocumentworkspace/Document_Library/Aenean%20semper.doc</pageUrl>
            //<comment>fff</comment>
            //<CheckinType>0</CheckinType>

            if (DwsHelper.CheckVisitor())
            {
                return(false);
            }

            var path = DwsHelper.GetPathFromUrl(pageUrl);
            var node = Node.LoadNode(path);

            if (node != null)
            {
                if (node.Lock.Locked && node.LockedById == ContentRepository.User.Current.Id)
                {
                    try
                    {
                        var gc = node as GenericContent;
                        gc["CheckInComments"] = comment;
                        if (CheckinType == "0")
                        {
                            gc.CheckIn();       // from 1.5 -> 1.6
                        }
                        if (CheckinType == "1")
                        {
                            gc.Publish();       // from 1.5 -> 2.0
                        }
                        if (CheckinType == "2")
                        {
                            return(false);       // from 1.5 -> 1.5, not implemented
                        }
                        return(true);
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteException(ex);
                    }
                }
            }

            return(false);
        }
Exemple #5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.TrySkipIisCustomErrors = true;
            context.Response.Headers.Add("MicrosoftSharePointTeamServices", "14.0.0.5128");
            if (DwsHelper.CheckVisitor())
            {
                return;
            }

            var requestPath = PortalContext.Current.RequestedUri.AbsolutePath.ToLower();

            // mock workflow.asmx -> we don't implement, simply return HTTP 200
            if (requestPath.EndsWith("_vti_bin/workflow.asmx"))
            {
                HandleWorkflow(context);
                return;
            }

            // initial request to _vti_inf.html
            if (requestPath.EndsWith("_vti_inf.html"))
            {
                HandleVtiInf(context);
                return;
            }

            var method = context.Request.Form["method"];

            if (method == null)
            {
                // check inputstream's first line
                using (var reader = new System.IO.StreamReader(context.Request.InputStream))
                {
                    var firstLine = reader.ReadLine();
                    if (!string.IsNullOrEmpty(firstLine))
                    {
                        var decodedFirstLine = HttpUtility.UrlDecode(firstLine);

                        if (decodedFirstLine.StartsWith("method=put document"))
                        {
                            // seek to end of first line (also skip end-of-line char)
                            using (var resultStream = new OffsetStream(reader.BaseStream, firstLine.Length + 1))
                            {
                                resultStream.Position = 0;
                                HandleAuthorPutDocument(context, decodedFirstLine, resultStream);
                            }
                            return;
                        }
                    }
                }
                HandleError(context);
                return;
            }


            if (requestPath.EndsWith("_vti_rpc"))
            {
                if (method.StartsWith("server version"))
                {
                    HandleServerVersion(context);
                    return;
                }
                if (method.StartsWith("url to web url"))
                {
                    HandleUrlToWebUrl(context);
                    return;
                }
            }

            if (requestPath.EndsWith("_vti_aut/author.dll"))
            {
                // method=open+service%3a12%2e0%2e0%2e6415&service%5fname=%2f
                if (method.StartsWith("open service"))
                {
                    HandleAuthorOpenService(context);
                    return;
                }
                if (method.StartsWith("getDocsMetaInfo"))
                {
                    HandleAuthorGetDocsMetaInfo(context);
                    return;
                }
                if (method.StartsWith("get document"))
                {
                    HandleError(context);
                    return;
                }
                if (method.StartsWith("put document"))
                {
                    // this is handled with inputstream's first line above
                    HandleError(context);
                    return;
                }
                if (method.StartsWith("checkout document"))
                {
                    HandleAuthorCheckoutDocument(context);
                    return;
                }
            }

            context.Response.Flush();
            context.Response.End();
        }
Exemple #6
0
        public VersionOperationResult GetVersions(string fileName)
        {
            if (DwsHelper.CheckVisitor() || string.IsNullOrEmpty(fileName))
            {
                return(null);
            }

            var url  = this.RequestUrl + "/" + fileName;
            var path = RepositoryPath.Combine(this.RequestPath, fileName);
            var file = Node.Load <GenericContent>(path);

            if (file == null)
            {
                // maybe it is a full path or url (Office 2013) instead of a name
                path = DwsHelper.GetPathFromUrl(fileName);
                file = Node.Load <GenericContent>(path);

                // re-set the url
                if (file != null)
                {
                    var bUrl   = file.BrowseUrl;
                    var domain = new Uri(this.RequestUrl).GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped);

                    // remove query string parameters
                    url = new Uri(domain + bUrl).GetComponents(UriComponents.SchemeAndServer | UriComponents.Path, UriFormat.SafeUnescaped);
                }
            }

            if (file == null)
            {
                return(null);
            }

            var list = file.ContentListId;

            var vr = new VersionOperationResult();

            vr.results                    = new VersionResults();
            vr.results.list               = new VersionResultsList();
            vr.results.list.id            = list == 0 ? string.Empty : list.ToString();
            vr.results.settings           = new VersionResultsSettings();
            vr.results.settings.url       = url;
            vr.results.versioning         = new VersionResultsVersioning();
            vr.results.versioning.enabled = file.VersioningMode > VersioningType.None ? (byte)1 : (byte)0;

            var versionData = new List <VersionData>();

            foreach (var version in file.Versions)
            {
                var createdBy   = version.VersionModifiedBy as User;
                var fileVersion = version as File;

                var vd = new VersionData();
                vd.version       = String.Format("{0}{1}.{2}", file.Version == version.Version ? "@" : String.Empty, version.Version.Major, version.Version.Minor);
                vd.url           = url + "?version=" + version.Version;
                vd.created       = version.VersionCreationDate.ToString();
                vd.createdRaw    = version.VersionCreationDate.ToString("yyyy-MM-ddThh:mm:ssZ");
                vd.createdBy     = createdBy == null ? string.Empty : createdBy.Username;
                vd.createdByName = createdBy == null ? string.Empty : createdBy.DisplayName;
                vd.size          = fileVersion == null ? (ulong)0 : (ulong)fileVersion.Size;
                vd.comments      = version.GetProperty <string>("CheckInComments") ?? string.Empty;

                versionData.Add(vd);
            }

            vr.results.result = versionData.ToArray();

            return(vr);
        }
Exemple #7
0
        public void ProcessRequest(HttpContext context)
        {
            #region Trace
            //string traceMessage = string.Concat("===== FPP ===== Path: '", context.Request.Path, "'", Environment.NewLine);
            //traceMessage = string.Concat(traceMessage, "   Authenticated: ", HttpContext.Current.User.Identity.IsAuthenticated.ToString(), ", ", "UserName: "******"   HEADERS: ", Environment.NewLine);

            //foreach (var x in context.Request.Headers.AllKeys)
            //{
            //    traceMessage = string.Concat(traceMessage, string.Format("      {0}={1}", x, context.Request.Headers[x]));
            //    traceMessage = string.Concat(traceMessage, Environment.NewLine);
            //}

            //System.Diagnostics.Trace.Write(traceMessage);
            #endregion

            context.Response.TrySkipIisCustomErrors = true;
            context.Response.Headers.Add("MicrosoftSharePointTeamServices", "14.0.0.5128");
            if (DwsHelper.CheckVisitor())
            {
                return;
            }

            var requestPath = PortalContext.Current.RequestedUri.AbsolutePath.ToLower();
            //System.Diagnostics.Trace.Write("   REQUESTPATH: " + requestPath);

            // mock workflow.asmx -> we don't implement, simply return HTTP 200
            if (requestPath.EndsWith("_vti_bin/workflow.asmx"))
            {
                HandleWorkflow(context);
                return;
            }

            // initial request to _vti_inf.html
            if (requestPath.EndsWith("_vti_inf.html"))
            {
                HandleVtiInf(context);
                return;
            }

            var method = context.Request.Form["method"];

            //System.Diagnostics.Trace.Write("   FPP METHOD: " + method);

            if (method == null)
            {
                // check inputstream's first line
                using (var reader = new System.IO.StreamReader(context.Request.InputStream))
                {
                    var firstLine = reader.ReadLine();
                    if (!string.IsNullOrEmpty(firstLine))
                    {
                        var decodedFirstLine = HttpUtility.UrlDecode(firstLine);
                        //System.Diagnostics.Trace.Write("   FPP CONTENT 1st line: " + decodedFirstLine);

                        if (decodedFirstLine.StartsWith("method=put document"))
                        {
                            // seek to end of first line (also skip end-of-line char)
                            reader.BaseStream.Position = firstLine.Length + 1;

                            var resultStream = new System.IO.MemoryStream();
                            reader.BaseStream.CopyTo(resultStream);
                            resultStream.Position = 0;

                            HandleAuthorPutDocument(context, decodedFirstLine, resultStream);
                            return;
                        }
                    }
                }
                HandleError(context);
                return;
            }


            if (requestPath.EndsWith("_vti_rpc"))
            {
                if (method.StartsWith("server version"))
                {
                    HandleServerVersion(context);
                    return;
                }
                if (method.StartsWith("url to web url"))
                {
                    HandleUrlToWebUrl(context);
                    return;
                }
            }

            if (requestPath.EndsWith("_vti_aut/author.dll"))
            {
                //method=open+service%3a12%2e0%2e0%2e6415&service%5fname=%2f
                if (method.StartsWith("open service"))
                {
                    HandleAuthorOpenService(context);
                    return;
                }
                if (method.StartsWith("getDocsMetaInfo"))
                {
                    HandleAuthorGetDocsMetaInfo(context);
                    return;
                }
                if (method.StartsWith("get document"))
                {
                    HandleError(context);
                    return;
                }
                if (method.StartsWith("put document"))
                {
                    // this is handled with inputstream's first line above
                    HandleError(context);
                    return;
                }
                if (method.StartsWith("checkout document"))
                {
                    HandleAuthorCheckoutDocument(context);
                    return;
                }
            }

            context.Response.Flush();
            context.Response.End();
        }