02-15-2009 01:28 AM
WindowsApplication1.AuthenticationService.AuthenticationService asvc = new WindowsApplication1.AuthenticationService.AuthenticationService();
AuthenticationResult ar = asvc.startSession("admin", "admin");
VersioningService vs = new VersioningService();
string repID = ("xyz");
string docID = ("abc");
string docRefId = docID;
bool b = vs.checkOut(repID, ref docRefId);
I was expecting an exception to be generated for giving invalid parameters, but the exception generated was about target service is null. It seems VersioningService is not exposed at URL/alfresco/api/VersioningService. RepositoryService rs = new RepositoryService();
rs.Credentials = asvc.Credentials;
Store[] stores = rs.getStores();
The exception which got generated was about Unauthorization. It was simple to figure out the cause, I was not passing in the security token, it was hard to figure out how to pass that. I was stuck.
public enum StoreEnum {
/// <remarks/>
workspace,
/// <remarks/>
versionStore,
/// <remarks/>
user,
/// <remarks/>
search,
/// <remarks/>
http,
/// <remarks/>
system,
}
public enum StoreEnum {
/// <remarks/>
workspace,
/// <remarks/>
versionStore,
/// <remarks/>
user,
/// <remarks/>
search,
/// <remarks/>
http,
/// <remarks/>
system,
archive,
avm,
}
private void CheckOut_Click(object sender, EventArgs e)
{
ListViewItem item = listViewBrowse.SelectedItems[0];
if (item != null)
{
ResultSetRowNode node = item.Tag as ResultSetRowNode;
if (node != null)
{
if (node.type.Contains("folder") == false)
{
// Create the reference for the node selected
Alfresco.AuthoringWebService.Store spacesStore2 = new Alfresco.AuthoringWebService.Store();
spacesStore2.scheme = Alfresco.AuthoringWebService.StoreEnum.workspace;
spacesStore2.address = "SpacesStore";
Alfresco.AuthoringWebService.Reference reference = new Alfresco.AuthoringWebService.Reference();
reference.store = spacesStore2;
reference.uuid = node.id;
// Lets try to check out
Alfresco.AuthoringWebService.Predicate predicate = new Alfresco.AuthoringWebService.Predicate();
predicate.Items = new Object[] { reference };
Alfresco.AuthoringWebService.ParentReference pr = new Alfresco.AuthoringWebService.ParentReference();
pr.store = spacesStore2; ;
pr.uuid = this.currentReference.uuid;
pr.associationType = Constants.ASSOC_CONTAINS;
pr.childName = Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, item.Text);
this.authoringService.checkout(predicate, pr);
}
else
{
// show message that a folder has been selected
}
}
}
}
private void GetOriginalVersion_Click(object sender, EventArgs e)
{
Alfresco.RepositoryWebService.Store[] stores = this.repoService.getStores();
Alfresco.RepositoryWebService.Store vStore = stores[3]; // from data, I found out that this is for Versioned store
ListViewItem item = listViewBrowse.SelectedItems[0];
if (item != null)
{
ResultSetRowNode node = item.Tag as ResultSetRowNode;
if (node != null)
{
if (node.type.Contains("folder") == false)
{
// Create the reference for the node selected
Alfresco.AuthoringWebService.Store spacesStore2 = new Alfresco.AuthoringWebService.Store();
spacesStore2.scheme = Alfresco.AuthoringWebService.StoreEnum.workspace;
spacesStore2.address = "SpacesStore";
Alfresco.AuthoringWebService.Reference reference = new Alfresco.AuthoringWebService.Reference();
reference.store = spacesStore2;
reference.uuid = node.id;
VersionHistory VH = this.authoringService.getVersionHistory(reference);
int i = 0;
char[] temp = new char[1];
temp[0] = '0';
string versions = new string(temp);
Alfresco.AuthoringWebService.Version first;
foreach (Alfresco.AuthoringWebService.Version version in VH.versions)
{
if (i == 0)
first = version;
versions += version.label + (";") + version.id.uuid + (";");
}
{
// Create the reference for the node selected
Alfresco.ContentWebService.Store spacesStore3 = new Alfresco.ContentWebService.Store();
spacesStore3.scheme = Alfresco.ContentWebService.StoreEnum.versionStore;
spacesStore3.address = vStore.address;
Alfresco.ContentWebService.Reference reference1 = new Alfresco.ContentWebService.Reference();
reference1.store = spacesStore3;
reference1.uuid = VH.versions[VH.versions.GetUpperBound(0)].id.uuid;
// Lets try and get the content
Alfresco.ContentWebService.Predicate predicate = new Alfresco.ContentWebService.Predicate();
predicate.Items = new Object[] { reference1 };
Content[] contents = this.contentService.read(predicate, "{http://www.alfresco.org/model/content/1.0}content");
Content content = contents[0];
if (content.url != null && content.url.Length != 0)
{
string url = content.url + "?ticket=" + AuthenticationUtils.Ticket;
webBrowser.Url = new Uri(url);
}
}
}
else
{
// show message that a folder has been selected
}
}
}
}
}
}
03-22-2009 11:29 PM
03-24-2009 06:03 AM
private static void addSecurityHeader(Microsoft.Web.Services3.WebServicesClientProtocol service)
and let RepositoryService derive from Microsoft.Web.Services3.WebServicesClientProtocol, rather than from SoapHttpClientProtocol (in alfresco-dotNet-0.2Beta\Alfresco\Web References\RepositoryWebService\Reference.cs)public partial class RepositoryService : Microsoft.Web.Services3.WebServicesClientProtocol
Do this for all the services.03-24-2009 09:38 PM
03-25-2009 01:46 PM
public enum StoreEnum {
/// <remarks/>
workspace,
/// <remarks/>
versionStore,
/// <remarks/>
user,
/// <remarks/>
search,
/// <remarks/>
http,
/// <remarks/>
system,
archive,
avm,
}
04-09-2009 09:33 PM
04-14-2009 02:51 PM
04-16-2009 08:29 AM
04-22-2009 06:40 AM
04-30-2009 10:30 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.