09-30-2014 08:06 AM
09-30-2014 10:09 AM
HttpClient client = new HttpClient();
client.getState().setCredentials(
new AuthScope("localhost", 8080, "Alfresco"),
new UsernamePasswordCredentials("admin", "admin"));
String apiurl = "http://localhost:8080/alfresco/service/api/tags/workspace/SpacesStore/tag1";
DeleteMethod delete = new DeleteMethod(apiurl);
try {
delete.setDoAuthentication(true);
int status = client.executeMethod(delete);
if (status != HttpStatus.SC_OK) {
System.err.println("Method failed: " + delete.getStatusLine());
}
String resultString = delete.getResponseBodyAsString();
System.out.println(resultString);
} catch (Exception e) {
e.printStackTrace();
} finally {
delete.releaseConnection();
}
09-30-2014 11:14 AM
public string sendDelete(string endPoint)
{
HttpWebRequest request = CreateWebRequestDelete(endPoint);
try
{
using (var response = (HttpWebResponse)request.GetResponse())
{
var responseValue = string.Empty;
if (response.StatusCode != HttpStatusCode.OK)
{
string message = String.Format("DELETE failed. Received HTTP {0}", response.StatusCode);
throw new ApplicationException(message);
}
// grab the response
using (var responseStream = response.GetResponseStream())
{
using (var reader = new StreamReader(responseStream))
{
responseValue = reader.ReadToEnd();
}
}
return responseValue;
}
}
catch (Exception ex)
{
return null;
}
}
private HttpWebRequest CreateWebRequestDelete(string endPoint)
{
var request = (HttpWebRequest)WebRequest.Create(endPoint);
request.Method = "DELETE";
request.ContentLength = 0;
request.ContentType = "text/xml";
return request;
}
public string deleteTag(string nameTag)
{
try
{
String ticket = admon.getTicketConector();
String url = server + "/alfresco/service/api/tags/workspace/SpacesStore/" + nameTag + "?alf_ticket=" + ticket;
return sendDelete(url);
}
catch(Exception ex)
{
throw ex;
}
}
10-01-2014 02:09 AM
public string sendDelete(string endPoint)
{
HttpWebRequest request = CreateWebRequestDelete(endPoint);
try
{
using (var response = (HttpWebResponse)request.GetResponse())
{
var responseValue = string.Empty;
if (response.StatusCode != HttpStatusCode.OK)
{
string message = String.Format("DELETE failed. Received HTTP {0}", response.StatusCode);
throw new ApplicationException(message);
}
// grab the response
using (var responseStream = response.GetResponseStream())
{
using (var reader = new StreamReader(responseStream))
{
responseValue = reader.ReadToEnd();
}
}
Console.WriteLine(responseValue);
return responseValue;
}
}
catch (Exception ex)
{
return null;
}
}
private HttpWebRequest CreateWebRequestDelete(string endPoint)
{
var request = (HttpWebRequest)WebRequest.Create(endPoint);
request.Method = "DELETE";
request.ContentLength = 0;
request.ContentType = "text/xml";
return request;
}
public string deleteTag(string nameTag)
{
try
{
String ticket = getTicketConector();
String url = server + "alfresco/service/api/tags/workspace/SpacesStore/" + nameTag + "?alf_ticket=" + ticket;
return sendDelete(url);
}
catch (Exception ex)
{
throw ex;
}
}
public string getTicketConector()
{
String ticket = null;
string URI = server + "alfresco/service/api/login?u=admin&pw=admin";
HttpWebRequest request = WebRequest.Create(URI) as HttpWebRequest;
//request.Method = "POST";
//request.ContentType = "application/x-www-form-urlencoded";
try
{
using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
{
StreamReader sr = new StreamReader(response.GetResponseStream());
XmlDocument xml = new XmlDocument();
xml.LoadXml(sr.ReadToEnd());
XmlNode root = xml.SelectSingleNode("/ticket");
ticket = root.InnerText;
}
}
catch (Exception e)
{
return (e.Message + Environment.NewLine + e.StackTrace);
}
return ticket;
}
10-01-2014 03:39 AM
10-01-2014 05:51 AM
10-01-2014 04:50 PM
10-01-2014 09:13 PM
02-12-2015 11:04 AM
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.