08-02-2013 06:01 AM
// get the sample user connection
var connectionId = "cmis-sample-connection"
var cmisConnection = cmis.getConnection(connectionId)
if (cmisConnection == null) {
// if no connection exists, talk to the local server
cmisConnection = cmis.getConnection()
}
var cmisSession = cmisConnection.getSession()
// get arguments
var path = args["path"]
if (path != null )
{
// get path folder
var parentFolder = cmisSession.getObjectByPath(path)
//delete folder
parentFolder.deleteFolder(true, UnfileObject.DELETE, true);
}
08-02-2013 10:18 PM
08-06-2013 01:59 AM
//Delete Folder
string endpointAddress = @"http://localhost:8080/alfresco/service/cmis/p/User Homes/Folder to be deleted/tree";
GetWebScriptResponse("DELETE", string.Empty, endpointAddress, "admin", "admin");
public static string GetWebScriptResponse(string method, string postData, string endpointAddress, string username, string password)
{
string _auth = string.Format("{0}:{1}", username, password);
string _enc = Convert.ToBase64String(Encoding.ASCII.GetBytes(_auth));
string _cred = string.Format("{0} {1}", "Basic", _enc);
/* WebProxy proxyObject = new WebProxy("http://youralfrescowebsite:8080/',true);*/
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(endpointAddress);
/* req.Proxy = proxyObject;*/
req.Timeout = 20 * 60 * 1000;
req.ReadWriteTimeout = 20 * 60 * 1000;
req.Method = method;
if (postData.Length > 0)
{
req.ContentType = "application/json;charset=UTF-8";
req.ContentLength = postData.Length;
}
req.AuthenticationLevel = System.Net.Security.AuthenticationLevel.MutualAuthRequired;
NetworkCredential nc = new NetworkCredential(username, password);
req.Credentials = nc;
req.Headers[HttpRequestHeader.Authorization] = _cred;
string response = null;
Stream dataStream = null;
try
{
if (POST.Equals(method) || PUT.Equals(method))
{
using (StreamWriter sw = new StreamWriter(req.GetRequestStream(),
System.Text.Encoding.ASCII))
{
sw.Write(postData);
sw.Flush();
}
}
using (StreamReader sr = new StreamReader(req.GetResponse().GetResponseStream()))
{
response = sr.ReadToEnd();
}
req.GetResponse().Close();
}
catch (Exception e)
{
response = "Exception: " + e.Message + "; " + e.ToString();
}
return response;
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.