public static void Execute() { Console.WriteLine("AuthRepositoryManagement - start"); // // 1. Connect to the DeployR Server // RClient rClient = Utility.Connect(); // // 2. Authenticate the user // RUser rUser = Utility.Authenticate(rClient); // // 3. Create a file in the authenticated user's private // repository and set shared access on the file so // other authenticated users can access the file. // RepoUploadOptions options = new RepoUploadOptions(); options.filename = "hello.txt"; options.sharedUser = true; String fileContent = "Hello World!"; RRepositoryFile rRepositoryFile = rUser.writeFile(fileContent, options); // // 4. Download working directory file content using // standard Java URL. // String fileURL = rRepositoryFile.download(); // // 5. Retrieve a list of files in the authenticated user's // private repository. // List<RRepositoryFile> files = rUser.listFiles(); foreach(RRepositoryFile file in files) { Console.WriteLine("AuthRepositoryManagement: private repository, " + "found file name=" + file.about().filename + ", directory=" + file.about().directory + ", access=" + file.about().access); } // // 6. Cleanup // Utility.Cleanup(rUser, rClient); Console.WriteLine("AuthRepositoryManagement - end"); }
static public void uploadDirectory(String file, RepoUploadOptions options, RClient client, String uri) { 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("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("newversion", options.newversion.ToString()); parameters.Add("newversionmsg", HttpUtility.UrlEncode(options.newversionmsg)); } //call the server JSONResponse jresponse = HTTPUtilities.callRESTFileUploadPost(uri, parameters, file, ref client); }
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); }
/// <summary> /// Upload files in a zip archive to repository-managed user directory /// </summary> /// <param name="file">Full path to the zip file to be uploaded</param> /// <param name="options">RepoUploadOptions object to apply to the upload</param> /// <remarks></remarks> public void uploadDirectory(String file, RepoUploadOptions options) { StringBuilder data = new StringBuilder(); Dictionary <String, String> parameters = new Dictionary <String, String>(); //set the url String uri = Constants.RREPOSITORYDIRECTORYUPLOAD; //create the input String if (!(options == null)) { parameters.Add("format", "json"); parameters.Add("directory", HttpUtility.UrlEncode(m_directoryDetails.name)); parameters.Add("descr", HttpUtility.UrlEncode(options.descr)); parameters.Add("newversion", options.newversion.ToString()); parameters.Add("shared", options.sharedUser.ToString()); parameters.Add("published", options.published.ToString()); parameters.Add("restricted", HttpUtility.UrlEncode(options.restricted)); } //call the server JSONResponse jresponse = HTTPUtilities.callRESTFileUploadPost(uri, parameters, file, ref m_client); }
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); }
/// <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> /// 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> /// Uploads a set of files in a single zip archive into an existing repository-managed user directory. The files are extracted from the zip archive and placed file-by-file into the directory. The options.filename property is ignored on this call and can be left blank. /// </summary> /// <param name="file">Name of zip file to upload</param> /// <param name="options">Repository upload options object</param> /// <remarks></remarks> public void uploadDirectory(String file, RepoUploadOptions options) { RUserRepositoryDirectoryImpl.uploadDirectory(file, options, m_client, Constants.RREPOSITORYDIRECTORYUPLOAD); }
/// <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 void uploadDirectory(String file, RepoUploadOptions options, RClient client, String uri) { 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("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("newversion", options.newversion.ToString()); parameters.Add("newversionmsg", HttpUtility.UrlEncode(options.newversionmsg)); } //call the server JSONResponse jresponse = HTTPUtilities.callRESTFileUploadPost(uri, parameters, file, ref client); }
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; }
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> /// Upload files in a zip archive to repository-managed user directory /// </summary> /// <param name="file">Full path to the zip file to be uploaded</param> /// <param name="options">RepoUploadOptions object to apply to the upload</param> /// <remarks></remarks> public void uploadDirectory(String file, RepoUploadOptions options) { StringBuilder data = new StringBuilder(); Dictionary<String, String> parameters = new Dictionary<String, String>(); //set the url String uri = Constants.RREPOSITORYDIRECTORYUPLOAD; //create the input String if (!(options == null)) { parameters.Add("format", "json"); parameters.Add("directory", HttpUtility.UrlEncode(m_directoryDetails.name)); parameters.Add("descr", HttpUtility.UrlEncode(options.descr)); parameters.Add("newversion", options.newversion.ToString()); parameters.Add("shared", options.sharedUser.ToString()); parameters.Add("published", options.published.ToString()); parameters.Add("restricted", HttpUtility.UrlEncode(options.restricted)); } //call the server JSONResponse jresponse = HTTPUtilities.callRESTFileUploadPost(uri, parameters, file, ref m_client); }