static public RRepositoryFile storeObject(RProjectDetails details, String name, Boolean sharedUser, Boolean published, String restricted, String descr, Boolean versioning, RClient client, String uri)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);
            StringBuilder   data        = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(details.id));
            data.Append("&name=" + HttpUtility.UrlEncode(name));
            data.Append("&descr=" + HttpUtility.UrlEncode(descr));
            data.Append("&version=" + versioning.ToString());
            data.Append("&shared=" + sharedUser.ToString());
            data.Append("&published=" + published.ToString());
            data.Append("&restricted=" + HttpUtility.UrlEncode(restricted));

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value <JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value <JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), client);
                }
            }

            return(returnValue);
        }
        /// <summary>
        /// Grant repository file to another user
        /// </summary>
        /// <param name="newauthor">name of the user to grant authorship</param>
        /// <param name="revokeauthor">name of the user to revoke authorship</param>
        /// <returns>RRepositoryFile object</returns>
        /// <remarks></remarks>
        public RRepositoryFile grant(String newauthor, String revokeauthor)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);
            StringBuilder   data        = new StringBuilder();

            //set the url
            String uri = Constants.RREPOSITORYFILEGRANT;

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&filename=" + HttpUtility.UrlEncode(m_fileDetails.filename));
            data.Append("&directory=" + HttpUtility.UrlEncode(m_fileDetails.directory));
            data.Append("&newauthor=" + HttpUtility.UrlEncode(newauthor));
            data.Append("&revokeauthor=" + HttpUtility.UrlEncode(revokeauthor));

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref m_client);

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value <JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value <JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), m_client);
                }
            }

            return(returnValue);
        }
        /// <summary>
        /// Update repository file
        /// </summary>
        /// <param name="restricted">indicates if file is restricted</param>
        /// <param name="sharedUser">indicates if file is shared</param>
        /// <param name="published">indicates if file is published</param>
        /// <param name="descr">description of the file</param>
        /// <param name="inputs">description of inputs to the script</param>
        /// <param name="outputs">description of outputs from the script</param>
        /// <returns>RRepositoryFile object</returns>
        /// <remarks></remarks>
        public RRepositoryFile update(String restricted, Boolean sharedUser, Boolean published, String descr, String inputs, String outputs)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);
            StringBuilder   data        = new StringBuilder();

            //set the url
            String uri = Constants.RREPOSITORYFILEUPDATE;

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&filename=" + HttpUtility.UrlEncode(m_fileDetails.filename));
            data.Append("&directory=" + HttpUtility.UrlEncode(m_fileDetails.directory));
            data.Append("&shared=" + sharedUser.ToString());
            data.Append("&published=" + published.ToString());
            data.Append("&restricted=" + HttpUtility.UrlEncode(restricted));
            data.Append("&descr=" + HttpUtility.UrlEncode(descr));
            data.Append("&inputs=" + HttpUtility.UrlEncode(inputs));
            data.Append("&outputs=" + HttpUtility.UrlEncode(outputs));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref m_client);

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value <JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value <JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), m_client);
                }
            }

            return(returnValue);
        }
        public static RRepositoryFile fetchFile(String filename, String author, String directory, String version, RClient client, String uri)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&filename=" + HttpUtility.UrlEncode(filename));
            data.Append("&directory=" + HttpUtility.UrlEncode(directory));
            data.Append("&author=" + HttpUtility.UrlEncode(author));
            data.Append("&version=" + HttpUtility.UrlEncode(version));

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTGet(uri, data.ToString(), ref client);

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value<JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value<JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), client);
                }
            }

            return returnValue;
        }
Beispiel #5
0
        static public RProjectFile loadFile(RProjectDetails details, RRepositoryFile file, RClient client, String uri)
        {
            RProjectFile  returnValue = default(RProjectFile);
            StringBuilder data        = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(details.id));
            data.Append("&filename=" + HttpUtility.UrlEncode(file.about().filename));
            data.Append("&directory=" + HttpUtility.UrlEncode(file.about().directory));
            data.Append("&author=" + HttpUtility.UrlEncode(file.about().author));
            data.Append("&version=" + HttpUtility.UrlEncode(file.about().version));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            if (!(jresponse.JSONMarkup["directory"] == null))
            {
                JObject jdir = jresponse.JSONMarkup["directory"].Value <JObject>();
                if (!(jdir["file"] == null))
                {
                    JObject jfile = jdir["file"].Value <JObject>();
                    returnValue = new RProjectFile(new JSONResponse(jfile, true, "", 0), client, details.id);
                }
            }

            return(returnValue);
        }
        private void parseRepositoryDirectory(JSONResponse jresponse, ref RRepositoryDirectoryDetails directoryDetails)
        {
            Boolean systemDirectory      = default(Boolean);
            List <RRepositoryFile> files = new List <RRepositoryFile>();

            JObject jdir = jresponse.JSONMarkup;

            if (!(jdir == null))
            {
                String name = JSONUtilities.trimXtraQuotes(jdir["directory"].ToString());
                if ((name == Constants.SYSTEM_SHARED) || (name == Constants.SYSTEM_RESTRICTED) || (name == Constants.SYSTEM_PUBLIC))
                {
                    systemDirectory = true;
                }
                else
                {
                    systemDirectory = false;
                }

                if (!(jdir["files"] == null))
                {
                    JArray jvalues = jdir["files"].Value <JArray>();
                    foreach (var j in jvalues)
                    {
                        if (j.Type != JTokenType.Null)
                        {
                            RRepositoryFile file = new RRepositoryFile(new JSONResponse(j.Value <JObject>(), true, "", 0), m_client);
                            files.Add(file);
                        }
                    }
                }

                directoryDetails = new RRepositoryDirectoryDetails(name, systemDirectory, files);
            }
        }
Beispiel #7
0
        static public RRepositoryFile fetchFile(String filename, String author, String directory, String version, RClient client, String uri)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);
            StringBuilder   data        = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&filename=" + HttpUtility.UrlEncode(filename));
            data.Append("&directory=" + HttpUtility.UrlEncode(directory));
            data.Append("&author=" + HttpUtility.UrlEncode(author));
            data.Append("&version=" + HttpUtility.UrlEncode(version));

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTGet(uri, data.ToString(), ref client);

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value <JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value <JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), client);
                }
            }

            return(returnValue);
        }
        static public void loadObject(RProjectDetails details, RRepositoryFile file, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(details.id));
            if (!(file == null))
            {
                data.Append("&filename=" + HttpUtility.UrlEncode(file.about().filename));
                data.Append("&directory=" + HttpUtility.UrlEncode(file.about().directory));
                data.Append("&author=" + HttpUtility.UrlEncode(file.about().author));
                data.Append("&version=" + HttpUtility.UrlEncode(file.about().version));
            }

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);
        }
Beispiel #9
0
        static public RRepositoryFile uploadFile(String file, RepoUploadOptions options, RClient client, String uri)
        {
            RRepositoryFile             returnValue = default(RRepositoryFile);
            StringBuilder               data        = new StringBuilder();
            Dictionary <String, String> parameters  = new Dictionary <String, String>();

            //create the input String
            if (!(options == null))
            {
                parameters.Add("format", "json");
                parameters.Add("filename", HttpUtility.UrlEncode(options.filename));
                parameters.Add("directory", HttpUtility.UrlEncode(options.directory));
                parameters.Add("descr", HttpUtility.UrlEncode(options.descr));
                parameters.Add("shared", options.sharedUser.ToString());
                parameters.Add("published", options.published.ToString());
                parameters.Add("restricted", HttpUtility.UrlEncode(options.restricted));
                parameters.Add("inputs", HttpUtility.UrlEncode(options.inputs));
                parameters.Add("outputs", HttpUtility.UrlEncode(options.outputs));
                parameters.Add("newversion", options.newversion.ToString());
                parameters.Add("newversionmsg", HttpUtility.UrlEncode(options.newversionmsg));
            }
            else
            {
                parameters.Add("filename", HttpUtility.UrlEncode(Path.GetFileName(file)));
            }
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTFileUploadPost(uri, parameters, file, ref client);

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value <JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value <JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), client);
                    return(returnValue);
                }
            }

            return(returnValue);
        }
Beispiel #10
0
        static public RRepositoryFile transferFile(String url, RepoUploadOptions options, RClient client, String uri)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);
            StringBuilder   data        = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&url=" + HttpUtility.UrlEncode(url));
            if (!(options == null))
            {
                data.Append("&filename=" + HttpUtility.UrlEncode(options.filename));
                data.Append("&directory=" + HttpUtility.UrlEncode(options.directory));
                data.Append("&descr=" + HttpUtility.UrlEncode(options.descr));
                data.Append("&shared=" + options.sharedUser.ToString());
                data.Append("&published=" + options.published.ToString());
                data.Append("&restricted=" + HttpUtility.UrlEncode(options.restricted));
                data.Append("&inputs=" + HttpUtility.UrlEncode(options.inputs));
                data.Append("&outputs=" + HttpUtility.UrlEncode(options.outputs));
                data.Append("&newversion=" + options.newversion.ToString());
                data.Append("&newversionmsg=" + HttpUtility.UrlEncode(options.newversionmsg));
            }

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value <JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value <JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), client);
                    return(returnValue);
                }
            }

            return(returnValue);
        }
Beispiel #11
0
        /// <summary>
        /// Store project directory file in the repository
        /// </summary>
        /// <param name="options">RepoUploadOptions object describing the file</param>
        /// <returns>RRepositoryFile object</returns>
        /// <remarks></remarks>
        public RRepositoryFile store(RepoUploadOptions options)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);

            StringBuilder data = new StringBuilder();

            //set the url
            String uri = Constants.RPROJECTDIRECTORYSTORE;

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + m_project);
            data.Append("&filename=" + HttpUtility.UrlEncode(options.filename));
            data.Append("&directory=" + HttpUtility.UrlEncode(options.directory));
            data.Append("&descr=" + HttpUtility.UrlEncode(options.descr));
            data.Append("&shared=" + options.sharedUser.ToString());
            data.Append("&published=" + options.published.ToString());
            data.Append("&restricted=" + options.restricted.ToString());
            data.Append("&newversion=" + options.newversion.ToString());
            data.Append("&newversionmsg=" + HttpUtility.UrlEncode(options.newversionmsg));

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref m_client);

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value <JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value <JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), m_client);
                }
            }

            return(returnValue);
        }
        /// <summary>
        /// Write a file to the user repository
        /// </summary>
        /// <param name="text">text to write to the repository</param>
        /// <param name="options">Repository upload options object </param>
        /// <returns>RRepositoryFile object</returns>
        /// <remarks></remarks>
        public RRepositoryFile writeFile(String text, RepoUploadOptions options)
        {
            RRepositoryFile returnValue = RUserRepositoryFileImpl.writeFile(text, options, m_client, Constants.RREPOSITORYFILEWRITE);

            return(returnValue);
        }
        /// <summary>
        /// Upload a file to the user repository
        /// </summary>
        /// <param name="file">Full path to File to upload and import</param>
        /// <param name="options">Repository upload options object </param>
        /// <returns>RRepositoryFile object</returns>
        /// <remarks></remarks>
        public RRepositoryFile uploadFile(String file, RepoUploadOptions options)
        {
            RRepositoryFile returnValue = RUserRepositoryFileImpl.uploadFile(file, options, m_client, Constants.RREPOSITORYFILEUPLOAD);

            return(returnValue);
        }
        /// <summary>
        /// Transfer file to the user repository
        /// </summary>
        /// <param name="url">Full qualified URL of file to transfer to repository</param>
        /// <param name="options">Repository upload options object </param>
        /// <returns>RRepositoryFile object</returns>
        /// <remarks></remarks>
        public RRepositoryFile transferFile(String url, RepoUploadOptions options)
        {
            RRepositoryFile returnValue = RUserRepositoryFileImpl.transferFile(url, options, m_client, Constants.RREPOSITORYFILETRANSFER);

            return(returnValue);
        }
        public static RRepositoryFile writeFile(String text, RepoUploadOptions options, RClient client, String uri)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&text=" + HttpUtility.UrlEncode(text));
            if (!(options == null))
            {
                data.Append("&filename=" + HttpUtility.UrlEncode(options.filename));
                data.Append("&directory=" + HttpUtility.UrlEncode(options.directory));
                data.Append("&descr=" + HttpUtility.UrlEncode(options.descr));
                data.Append("&shared=" + options.sharedUser.ToString());
                data.Append("&published=" + options.published.ToString());
                data.Append("&restricted=" + HttpUtility.UrlEncode(options.restricted));
                data.Append("&inputs=" + HttpUtility.UrlEncode(options.inputs));
                data.Append("&outputs=" + HttpUtility.UrlEncode(options.outputs));
                data.Append("&newversion=" + options.newversion.ToString());
                data.Append("&newversionmsg=" + HttpUtility.UrlEncode(options.newversionmsg));
            }

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value<JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value<JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), client);
                }
            }

            return returnValue;
        }
        /// <summary>
        /// Update repository file
        /// </summary>
        /// <param name="restricted">indicates if file is restricted</param>
        /// <param name="sharedUser">indicates if file is shared</param>
        /// <param name="published">indicates if file is published</param>
        /// <param name="descr">description of the file</param>
        /// <param name="inputs">description of inputs to the script</param>
        /// <param name="outputs">description of outputs from the script</param>
        /// <returns>RRepositoryFile object</returns>
        /// <remarks></remarks>
        public RRepositoryFile update(String restricted, Boolean sharedUser, Boolean published, String descr, String inputs, String outputs)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);
            StringBuilder data = new StringBuilder();

            //set the url
            String uri = Constants.RREPOSITORYFILEUPDATE;
            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&filename=" + HttpUtility.UrlEncode(m_fileDetails.filename));
            data.Append("&directory=" + HttpUtility.UrlEncode(m_fileDetails.directory));
            data.Append("&shared=" + sharedUser.ToString());
            data.Append("&published=" + published.ToString());
            data.Append("&restricted=" + HttpUtility.UrlEncode(restricted));
            data.Append("&descr=" + HttpUtility.UrlEncode(descr));
            data.Append("&inputs=" + HttpUtility.UrlEncode(inputs));
            data.Append("&outputs=" + HttpUtility.UrlEncode(outputs));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref m_client);

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value<JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value<JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), m_client);
                }
            }

            return returnValue;
        }
        /// <summary>
        /// Grant repository file to another user
        /// </summary>
        /// <param name="newauthor">name of the user to grant authorship</param>
        /// <param name="revokeauthor">name of the user to revoke authorship</param>
        /// <returns>RRepositoryFile object</returns>
        /// <remarks></remarks>
        public RRepositoryFile grant(String newauthor, String revokeauthor)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);
            StringBuilder data = new StringBuilder();

            //set the url
            String uri = Constants.RREPOSITORYFILEGRANT;
            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&filename=" + HttpUtility.UrlEncode(m_fileDetails.filename));
            data.Append("&directory=" + HttpUtility.UrlEncode(m_fileDetails.directory));
            data.Append("&newauthor=" + HttpUtility.UrlEncode(newauthor));
            data.Append("&revokeauthor=" + HttpUtility.UrlEncode(revokeauthor));

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref m_client);

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value<JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value<JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), m_client);
                }
            }

            return returnValue;
        }
 /// <summary>
 /// load an object into the R workspace from a file in the repository
 /// </summary>
 /// <param name="file">RRepository object representing the file to load</param>
 /// <remarks></remarks>
 public void loadObject(RRepositoryFile file)
 {
     RProjectWorkspaceImpl.loadObject(m_projectDetails, file, m_client, Constants.RPROJECTWORKSPACELOAD);
 }
        public static RProjectFile loadFile(RProjectDetails details, RRepositoryFile file, RClient client, String uri)
        {
            RProjectFile returnValue = default(RProjectFile);
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(details.id));
            data.Append("&filename=" + HttpUtility.UrlEncode(file.about().filename));
            data.Append("&author=" + HttpUtility.UrlEncode(file.about().author));
            data.Append("&version=" + HttpUtility.UrlEncode(file.about().version));
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            if (!(jresponse.JSONMarkup["directory"] == null))
            {
                JObject jdir = jresponse.JSONMarkup["directory"].Value<JObject>();
                if (!(jdir["file"] == null))
                {
                    JObject jfile = jdir["file"].Value<JObject>();
                    returnValue = new RProjectFile(new JSONResponse(jfile, true, "", 0), client, details.id);
                }
            }

            return returnValue;
        }
        public static RRepositoryFile storeObject(RProjectDetails details, String name, Boolean sharedUser, Boolean published, String restricted, String descr, Boolean versioning, RClient client, String uri)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(details.id));
            data.Append("&name=" + HttpUtility.UrlEncode(name));
            data.Append("&descr=" + HttpUtility.UrlEncode(descr));
            data.Append("&version=" + versioning.ToString());
            data.Append("&shared=" + sharedUser.ToString());
            data.Append("&published=" + published.ToString());
            data.Append("&restricted=" + HttpUtility.UrlEncode(restricted));

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value<JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value<JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), client);
                }
            }

            return returnValue;
        }
        public static void loadObject(RProjectDetails details, RRepositoryFile file, RClient client, String uri)
        {
            StringBuilder data = new StringBuilder();

            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + HttpUtility.UrlEncode(details.id));
            if (!(file == null))
            {
                data.Append("&filename=" + HttpUtility.UrlEncode(file.about().filename));
                data.Append("&author=" + HttpUtility.UrlEncode(file.about().author));
                data.Append("&version=" + HttpUtility.UrlEncode(file.about().version));
            }

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref client);
        }
        public static RRepositoryFile uploadFile(String file, RepoUploadOptions options, RClient client, String uri)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);
            StringBuilder data = new StringBuilder();
            Dictionary<String, String> parameters = new Dictionary<String, String>();

            //create the input String
            if (!(options == null))
            {
                parameters.Add("format", "json");
                parameters.Add("filename", HttpUtility.UrlEncode(options.filename));
                parameters.Add("directory", HttpUtility.UrlEncode(options.directory));
                parameters.Add("descr", HttpUtility.UrlEncode(options.descr));
                parameters.Add("shared", options.sharedUser.ToString());
                parameters.Add("published", options.published.ToString());
                parameters.Add("restricted", HttpUtility.UrlEncode(options.restricted));
                parameters.Add("inputs", HttpUtility.UrlEncode(options.inputs));
                parameters.Add("outputs", HttpUtility.UrlEncode(options.outputs));
                parameters.Add("newversion", options.newversion.ToString());
                parameters.Add("newversionmsg", HttpUtility.UrlEncode(options.newversionmsg));
            }
            else
            {
                parameters.Add("filename", HttpUtility.UrlEncode(Path.GetFileName(file)));
            }
            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTFileUploadPost(uri, parameters, file, ref client);

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value<JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value<JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), client);
                    return returnValue;
                }
            }

            return returnValue;
        }
 /// <summary>
 /// load an object into the R workspace from a file in the repository
 /// </summary>
 /// <param name="file">RRepository object representing the file to load</param>
 /// <remarks></remarks>
 public void loadObject(RRepositoryFile file)
 {
     RProjectWorkspaceImpl.loadObject(m_projectDetails, file, m_client, Constants.RPROJECTWORKSPACELOAD);
 }
        /// <summary>
        /// Load file from user repository into project directory
        /// </summary>
        /// <param name="file">RRepositoryFile object to load</param>
        /// <returns>RProjectFile object created</returns>
        /// <remarks></remarks>
        public RProjectFile loadFile(RRepositoryFile file)
        {
            RProjectFile returnValue = RProjectDirectoryImpl.loadFile(m_projectDetails, file, m_client, Constants.RPROJECTDIRECTORYLOAD);

            return(returnValue);
        }
        /// <summary>
        /// Fetch the latest meta-data for a repository file
        /// </summary>
        /// <param name="filename">Repository filename to fetch</param>
        /// <param name="author">Author of the file</param>
        /// <param name="directory">Repository directory containing the file</param>
        /// <param name="version">Optional version of the file</param>
        /// <returns>RRepositoryFile object</returns>
        /// <remarks></remarks>
        public RRepositoryFile fetchFile(String filename, String author, String directory, String version)
        {
            RRepositoryFile returnValue = RUserRepositoryFileImpl.fetchFile(filename, author, directory, version, m_client, Constants.RREPOSITORYFILEFETCH);

            return(returnValue);
        }
        /// <summary>
        /// Load file from user repository into project directory
        /// </summary>
        /// <param name="file">RRepositoryFile object to load</param>
        /// <returns>RProjectFile object created</returns>
        /// <remarks></remarks>
        public RProjectFile loadFile(RRepositoryFile file)
        {
            RProjectFile returnValue = RProjectDirectoryImpl.loadFile(m_projectDetails, file, m_client, Constants.RPROJECTDIRECTORYLOAD);

            return returnValue;
        }
        /// <summary>
        /// save an object from the workspace to a repository file
        /// </summary>
        /// <param name="name">name of the object to save</param>
        /// <param name="descr">description of the object to save</param>
        /// <param name="versioning">indicate if versioning of the file should be enabled</param>
        /// <param name="restricted">indicates if file is restricted</param>
        /// <param name="sharedUser">indicates if file is shared</param>
        /// <param name="published">indicates if file is published</param>
        /// <returns>RRepositoryFile object</returns>
        /// <remarks></remarks>
        public RRepositoryFile storeObject(String name, String descr, Boolean versioning, Boolean sharedUser, Boolean published, String restricted)
        {
            RRepositoryFile returnValue = RProjectWorkspaceImpl.storeObject(m_projectDetails, name, sharedUser, published, restricted, descr, versioning, m_client, Constants.RPROJECTWORKSPACESTORE);

            return(returnValue);
        }
        /// <summary>
        /// Store project directory file in the repository
        /// </summary>
        /// <param name="options">RepoUploadOptions object describing the file</param>
        /// <returns>RRepositoryFile object</returns>
        /// <remarks></remarks>
        public RRepositoryFile store(RepoUploadOptions options)
        {
            RRepositoryFile returnValue = default(RRepositoryFile);

            StringBuilder data = new StringBuilder();

            //set the url
            String uri = Constants.RPROJECTDIRECTORYSTORE;
            //create the input String
            data.Append(Constants.FORMAT_JSON);
            data.Append("&project=" + m_project);
            data.Append("&filename=" + HttpUtility.UrlEncode(options.filename));
            data.Append("&directory=" + HttpUtility.UrlEncode(options.directory));
            data.Append("&descr=" + HttpUtility.UrlEncode(options.descr));
            data.Append("&shared=" + options.sharedUser.ToString());
            data.Append("&published=" + options.published.ToString());
            data.Append("&restricted=" + options.restricted.ToString());
            data.Append("&newversion=" + options.newversion.ToString());
            data.Append("&newversionmsg=" + HttpUtility.UrlEncode(options.newversionmsg));

            //call the server
            JSONResponse jresponse = HTTPUtilities.callRESTPost(uri, data.ToString(), ref m_client);

            if (!(jresponse.JSONMarkup["repository"] == null))
            {
                JObject jrepo = jresponse.JSONMarkup["repository"].Value<JObject>();
                if (!(jrepo["file"] == null))
                {
                    JObject jfile = jrepo["file"].Value<JObject>();
                    returnValue = new RRepositoryFile(new JSONResponse(jfile, true, "", 0), m_client);
                }
            }

            return returnValue;
        }
        private void parseRepositoryDirectory(JSONResponse jresponse, ref RRepositoryDirectoryDetails directoryDetails)
        {
            Boolean systemDirectory = default(Boolean);
            List<RRepositoryFile> files = new List<RRepositoryFile>();

            JObject jdir = jresponse.JSONMarkup;
            if (!(jdir == null))
            {

                String name = JSONUtilities.trimXtraQuotes(jdir["directory"].ToString());
                if ((name == Constants.SYSTEM_SHARED) || (name == Constants.SYSTEM_RESTRICTED) || (name == Constants.SYSTEM_PUBLIC))
                {
                    systemDirectory = true;
                }
                else
                {
                    systemDirectory = false;
                }

                if (!(jdir["files"] == null))
                {
                    JArray jvalues = jdir["files"].Value<JArray>();
                    foreach (var j in jvalues)
                    {
                        if (j.Type != JTokenType.Null)
                        {
                            RRepositoryFile file = new RRepositoryFile(new JSONResponse(j.Value<JObject>(), true, "", 0), m_client);
                            files.Add(file);
                        }
                    }
                }

                directoryDetails = new RRepositoryDirectoryDetails(name, systemDirectory, files);

            }
        }