public static NodeBase GetNodeById(string documentId) { NodeBase lNode = null; Alfresco.RepositoryWebService.Store spacesStore = new Alfresco.RepositoryWebService.Store(); spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; spacesStore.address = Constants.SPACES_STORE; // Create a query object Alfresco.RepositoryWebService.Query query = new Alfresco.RepositoryWebService.Query(); query.language = Constants.QUERY_LANG_LUCENE; query.statement = string.Format("@sys\\:node-uuid:\"{0}\"", documentId); QueryResult result = WebServiceFactory.getRepositoryService().query(spacesStore, query, true); if (result.resultSet.rows != null) { ResultSetRow row = result.resultSet.rows[0]; lNode = new NodeBase(); lNode.properties = new NamedValue[row.columns.Length]; row.columns.CopyTo(lNode.properties, 0); lNode.id = documentId; } return(lNode); }
public frmTreeViewBrowse(String selectUuid) { try { InitializeComponent(); this.selectedUuid = selectUuid; // Initialise the reference to the spaces store this.spacesStore = new Alfresco.RepositoryWebService.Store(); this.spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; this.spacesStore.address = "SpacesStore"; // Load the images in an ImageList. ImageList myImageList = new ImageList(); // myImageList.Images.Add(Image.FromFile("C:\\Temp\\ftv2folderclosed.gif")); // myImageList.Images.Add(Image.FromFile("C:\\Temp\\ftv2folderopen.gif")); myImageList.Images.Add(KofaxAlfrescoRelease_v1.Properties.Resources.ftv2folderclosed); myImageList.Images.Add(KofaxAlfrescoRelease_v1.Properties.Resources.ftv2folderopen); // Assign the ImageList to the TreeView. treeView1.ImageList = myImageList; treeView1.ImageIndex = 0; treeView1.SelectedImageIndex = 1; } catch (Exception e) { Log log = new Log(); log.ErrorLog(".\\log\\", "constructor frmTreeViewBrowse " + e.Message, e.StackTrace); } }
private bool isNewContent(String spaceUuid, String name) { bool isNew = true; // Create a query object Alfresco.RepositoryWebService.Query query = new Alfresco.RepositoryWebService.Query(); query.language = Alfresco.RepositoryWebService.QueryLanguageEnum.lucene; // Create a query object String search = "+PARENT:\"workspace://SpacesStore/" + spaceUuid + "\" +@cm\\:name:\"" + name + "\""; query.statement = search; // Initialise the reference to the spaces store Alfresco.RepositoryWebService.Store spacesStore = new Alfresco.RepositoryWebService.Store(); spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; spacesStore.address = "SpacesStore"; QueryResult result = this.repoService.query(spacesStore, query, true); if (result.resultSet.rows != null) { isNew = false; } return(isNew); }
//********************************************************** // Function: OpenScript() // Scope: internal // Overview: Script initialization point. Perform any // necessary initialization such as logging // in to a remote data source, allocated any // necessary resources, etc. // Params: none // Returns: One of the following: // KFX_REL_SUCCESS, KFX_REL_ERROR // Called By: The Batch Release Manager. Called once // when the script object is loaded. //********************************************************** public AscentRelease.KfxReturnValue OpenScript() { // Start the Alfresco session try { string repository = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_REPOSITORY); WebServiceFactory.setEndpointAddress(repository); string userName = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_USERNAME); string password = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_PASSWORD); AuthenticationUtils.startSession(userName, password); this.repoService = WebServiceFactory.getRepositoryService(); // the uuid of the location to be saved this.locationUuid = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_LOCATION_UUID); this.contentType = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_CONTENT_TYPE); this.imageContentProp = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_IMAGE); this.ocrContentProp = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_OCR); this.pdfContentProp = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_PDF); // Initialise the reference to the spaces store this.spacesStore = new Alfresco.RepositoryWebService.Store(); spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; spacesStore.address = "SpacesStore"; return(AscentRelease.KfxReturnValue.KFX_REL_SUCCESS); } catch (Exception) { return(AscentRelease.KfxReturnValue.KFX_REL_ERROR); } }
public TreeViewBrowse() { InitializeComponent(); // Initialise the reference to the spaces store this.spacesStore = new Alfresco.RepositoryWebService.Store(); this.spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; this.spacesStore.address = "SpacesStore"; }
public void CanPerformSearches() { AuthenticationUtils.startSession("admin", "admin"); try { RepositoryService repositoryService = WebServiceFactory.getRepositoryService(); Store spacesStore = new Store(StoreEnum.workspace, "SpacesStore"); String luceneQuery = "PATH:\"/app:company_home\""; Query query = new Query(Constants.QUERY_LANG_LUCENE, luceneQuery); QueryResult queryResult = repositoryService.query(spacesStore, query, false); ResultSet resultSet = queryResult.resultSet; ResultSetRow[] results = resultSet.rows; //your custom list IList<CustomResultVO> customResultList = new List<CustomResultVO>(); //retrieve results from the resultSet foreach(ResultSetRow resultRow in results) { ResultSetRowNode nodeResult = resultRow.node; //create your custom value object CustomResultVO customResultVo = new CustomResultVO(); customResultVo.Id = nodeResult.id; customResultVo.Type = nodeResult.type; //retrieve properties from the current node foreach(NamedValue namedValue in resultRow.columns) { if (Constants.PROP_NAME.Equals(namedValue.name)) { customResultVo.Name = namedValue.value; } else if (Constants.PROP_DESCRIPTION.Equals(namedValue.name)) { customResultVo.Description = namedValue.value; } } //add the current result to your custom list customResultList.Add(customResultVo); } Assert.AreEqual(1, customResultList.Count); CustomResultVO firstResult = customResultList[0]; Assert.IsNotNull(firstResult.Id); Assert.AreEqual("{http://www.alfresco.org/model/content/1.0}folder", firstResult.Type); } finally { AuthenticationUtils.endSession(); } }
public void CanStoreNodes() { AuthenticationUtils.startSession("admin", "admin"); Store spacesStore = new Store(StoreEnum.workspace, "SpacesStore"); String name = "AWS Book " + DateTime.Now.Ticks; String description = "This is a content created with a sample of the book"; //custom value object CreateSampleVO createSampleVo = Builder.BuildCreateSampleVO(name, name, description); try { ParentReference parent = new ParentReference( spacesStore, null, "/app:company_home", Constants.ASSOC_CONTAINS, "{" + Constants.NAMESPACE_CONTENT_MODEL + "}" + name ); //build properties NamedValue[] properties = Builder.BuildCustomProperties(createSampleVo); //create operation CMLCreate create = new CMLCreate(); create.id = "1"; create.parent = parent; create.type = Constants.TYPE_CONTENT; create.property = properties; //build the CML object CML cml = new CML(); cml.create = new CMLCreate[]{ create }; //perform a CML update to create the node UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml); String expectedPath = "/app:company_home/cm:AWS_x0020_Book_x0020_"; Assert.IsTrue(result[0].destination.path.StartsWith(expectedPath)); } finally { AuthenticationUtils.endSession(); } }
private String getNodeUuidFromLocation(String spaceUuid, String name) { String uuid = ""; // Create a query object Alfresco.RepositoryWebService.Query query = new Alfresco.RepositoryWebService.Query(); query.language = Alfresco.RepositoryWebService.QueryLanguageEnum.lucene; String search = "+PARENT:\"workspace://SpacesStore/" + spaceUuid + "\" +@cm\\:name:\"" + name + "\""; query.statement = search; // Initialise the reference to the spaces store Alfresco.RepositoryWebService.Store spacesStore = new Alfresco.RepositoryWebService.Store(); spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; spacesStore.address = "SpacesStore"; QueryResult result = this.repoService.query(spacesStore, query, true); if (result.resultSet.rows != null) { uuid = result.resultSet.rows[0].node.id; } return(uuid); }
private void UploadNow(string fileName, string file) { // Initialise the reference to the spaces store Alfresco.RepositoryWebService.Store spacesStore = new Alfresco.RepositoryWebService.Store(); spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; spacesStore.address = "SpacesStore"; // Create the parent reference, the company home folder Alfresco.RepositoryWebService.ParentReference parentReference = new Alfresco.RepositoryWebService.ParentReference(); parentReference.store = spacesStore; //parentReference.path = "/app:company_home" parentReference.uuid = LocationUuid; parentReference.associationType = Constants.ASSOC_CONTAINS; parentReference.childName = Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, fileName); // Create the properties list NamedValue nameProperty = new NamedValue(); nameProperty.name = Constants.PROP_NAME; nameProperty.value = fileName; nameProperty.isMultiValue = false; NamedValue[] properties = new NamedValue[2]; properties[0] = nameProperty; nameProperty = new NamedValue(); nameProperty.name = Constants.PROP_TITLE; nameProperty.value = fileName; nameProperty.isMultiValue = false; properties[1] = nameProperty; // Create the CML create object CMLCreate create = new CMLCreate(); create.parent = parentReference; create.id = "1"; create.type = Constants.TYPE_CONTENT; create.property = properties; // Create and execute the cml statement CML cml = new CML(); cml.create = new CMLCreate[] { create }; UpdateResult[] updateResult = repoService.update(cml); // work around to cast Alfresco.RepositoryWebService.Reference to // Alfresco.ContentWebService.Reference Alfresco.RepositoryWebService.Reference rwsRef = updateResult[0].destination; Alfresco.ContentWebService.Reference newContentNode = new Alfresco.ContentWebService.Reference(); newContentNode.path = rwsRef.path; newContentNode.uuid = rwsRef.uuid; Alfresco.ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store(); cwsStore.address = "SpacesStore"; spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; newContentNode.store = cwsStore; // Open the file and convert to byte array FileStream inputStream = new FileStream(file, FileMode.Open); int bufferSize = (int)inputStream.Length; byte[] bytes = new byte[bufferSize]; inputStream.Read(bytes, 0, bufferSize); inputStream.Close(); ContentFormat contentFormat = new ContentFormat(); if (rdjpeg.Checked == true) { contentFormat.mimetype = "image/jpeg"; } else if (rdgif.Checked == true) { contentFormat.mimetype = "image/gif"; } else if (rdtiff.Checked == true) { contentFormat.mimetype = "image/tiff"; } WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, bytes, contentFormat); }
public static NodeBase GetNodeById(string documentId) { NodeBase lNode = null; Alfresco.RepositoryWebService.Store spacesStore = new Alfresco.RepositoryWebService.Store(); spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; spacesStore.address = Constants.SPACES_STORE; // Create a query object Alfresco.RepositoryWebService.Query query = new Alfresco.RepositoryWebService.Query(); query.language = Constants.QUERY_LANG_LUCENE; query.statement = string.Format("@sys\\:node-uuid:\"{0}\"", documentId); QueryResult result = WebServiceFactory.getRepositoryService().query(spacesStore, query, true); if (result.resultSet.rows != null) { ResultSetRow row = result.resultSet.rows[0]; lNode = new NodeBase(); lNode.properties = new NamedValue[row.columns.Length]; row.columns.CopyTo(lNode.properties, 0); lNode.id = documentId; } return lNode; }
private bool isNewContent(String spaceUuid, String name) { bool isNew = true; // Create a query object Alfresco.RepositoryWebService.Query query = new Alfresco.RepositoryWebService.Query(); query.language = Alfresco.RepositoryWebService.QueryLanguageEnum.lucene; // Create a query object String search = "+PARENT:\"workspace://SpacesStore/" + spaceUuid + "\" +@cm\\:name:\"" + name + "\""; query.statement = search; // Initialise the reference to the spaces store Alfresco.RepositoryWebService.Store spacesStore = new Alfresco.RepositoryWebService.Store(); spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; spacesStore.address = "SpacesStore"; QueryResult result = this.repoService.query(spacesStore, query, true); if (result.resultSet.rows != null) { isNew = false; } return isNew; }
private String getNodeUuidFromLocation(String spaceUuid, String name) { String uuid = ""; // Create a query object Alfresco.RepositoryWebService.Query query = new Alfresco.RepositoryWebService.Query(); query.language = Alfresco.RepositoryWebService.QueryLanguageEnum.lucene; String search = "+PARENT:\"workspace://SpacesStore/" + spaceUuid + "\" +@cm\\:name:\"" + name + "\""; query.statement = search; // Initialise the reference to the spaces store Alfresco.RepositoryWebService.Store spacesStore = new Alfresco.RepositoryWebService.Store(); spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; spacesStore.address = "SpacesStore"; QueryResult result = this.repoService.query(spacesStore, query, true); if (result.resultSet.rows != null) { uuid = result.resultSet.rows[0].node.id; } return uuid; }
//********************************************************** // Function: OpenScript() // Scope: internal // Overview: Script initialization point. Perform any // necessary initialization such as logging // in to a remote data source, allocated any // necessary resources, etc. // Params: none // Returns: One of the following: // KFX_REL_SUCCESS, KFX_REL_ERROR // Called By: The Batch Release Manager. Called once // when the script object is loaded. //********************************************************** public AscentRelease.KfxReturnValue OpenScript() { // Start the Alfresco session try { string repository = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_REPOSITORY); WebServiceFactory.setEndpointAddress(repository); string userName = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_USERNAME); string password = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_PASSWORD); AuthenticationUtils.startSession(userName, password); this.repoService = WebServiceFactory.getRepositoryService(); // the uuid of the location to be saved this.locationUuid = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_LOCATION_UUID); this.contentType = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_CONTENT_TYPE); this.imageContentProp = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_IMAGE); this.ocrContentProp = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_OCR); this.pdfContentProp = ReleaseUtils.getCustomProperty(this.releaseData.CustomProperties, ReleaseConstants.CUSTOM_PDF); // Initialise the reference to the spaces store this.spacesStore = new Alfresco.RepositoryWebService.Store(); spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; spacesStore.address = "SpacesStore"; return AscentRelease.KfxReturnValue.KFX_REL_SUCCESS; } catch (Exception) { return AscentRelease.KfxReturnValue.KFX_REL_ERROR; } }
/// <remarks/> public System.IAsyncResult Beginquery(Store store, Query query1, bool includeMetaData, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("query", new object[] { store, query1, includeMetaData}, callback, asyncState); }
public QueryResult query(Store store, [System.Xml.Serialization.XmlElementAttribute("query")] Query query1, bool includeMetaData) { object[] results = this.Invoke("query", new object[] { store, query1, includeMetaData}); return ((QueryResult)(results[0])); }
public void CanUpdateNodes() { AuthenticationUtils.startSession("admin", "admin"); Store spacesStore = new Store(StoreEnum.workspace, "SpacesStore"); String name = "AWS Book - Remove Child " + DateTime.Now.Ticks; String spaceNameForMove = "AWS Book - Remove Child Space Sample " + DateTime.Now.Ticks; String description = "This is a content created with a sample of the book"; //custom value object CreateSampleVO createSampleVo = Builder.BuildCreateSampleVO(name, name, description); CreateSampleVO createFolderSampleVo = Builder.BuildCreateSampleVO(spaceNameForMove, spaceNameForMove, description); try { //parent for the new node ParentReference parentForNode = new ParentReference( spacesStore, null, "/app:company_home", Constants.ASSOC_CONTAINS, "{" + Constants.NAMESPACE_CONTENT_MODEL + "}" + name ); //parent for the new space ParentReference parentForSpace = new ParentReference( spacesStore, null, "/app:company_home", Constants.ASSOC_CONTAINS, "{" + Constants.NAMESPACE_CONTENT_MODEL + "}" + spaceNameForMove ); //build properties NamedValue[] properties = Builder.BuildCustomProperties(createSampleVo); NamedValue[] propertiesForSpace = Builder.BuildCustomPropertiesForSpace(createFolderSampleVo); //create a node CMLCreate create = new CMLCreate(); create.id = "1"; create.parent = parentForNode; create.type = Constants.TYPE_CONTENT; create.property = properties; //create a space CMLCreate createSpace = new CMLCreate(); createSpace.id = "2"; createSpace.parent = parentForSpace; createSpace.type = Constants.TYPE_FOLDER; createSpace.property = propertiesForSpace; //build the CML object CML cmlAdd = new CML(); cmlAdd.create = new CMLCreate[] { create, createSpace }; //perform a CML update to create nodes UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cmlAdd); String expectedPath = "/app:company_home/cm:AWS_x0020_Book_x0020_-_x0020_Remove_x0020_Child_x0020_"; Assert.IsTrue(result[0].destination.path.StartsWith(expectedPath)); expectedPath = "/app:company_home/cm:AWS_x0020_Book_x0020_-_x0020_Remove_x0020_Child_x0020_Space_x0020_Sample_x0020_"; Assert.IsTrue(result[1].destination.path.StartsWith(expectedPath)); //create a predicate with the first CMLCreate result Reference referenceForNode = result[0].destination; Predicate sourcePredicate = new Predicate(new Reference[] { referenceForNode }, spacesStore, null); //create a reference from the second CMLCreate performed for space Reference referenceForTargetSpace = result[1].destination; //reference for the target space ParentReference targetSpace = new ParentReference(); targetSpace.store = spacesStore; targetSpace.path = referenceForTargetSpace.path; targetSpace.associationType = Constants.ASSOC_CONTAINS; targetSpace.childName = name; name = "AWS Book - Changed by CMLUpdate " + DateTime.Now.Ticks; createSampleVo.Name = name; createSampleVo.Title = name; createSampleVo.Description = "Changed by CMLUpdate " + description; //add versionable aspect to the node CMLAddAspect aspect = new CMLAddAspect(); aspect.aspect = Constants.ASPECT_VERSIONABLE; aspect.where = sourcePredicate; //update node CMLUpdate update = new CMLUpdate(); update.property = Builder.BuildCustomProperties(createSampleVo); update.where = sourcePredicate; CML cmlUpdate = new CML(); cmlUpdate.addAspect = new CMLAddAspect[] { aspect }; cmlUpdate.update = new CMLUpdate[] { update }; //perform a CML update WebServiceFactory.getRepositoryService().update(cmlUpdate); expectedPath = "/app:company_home/cm:AWS_x0020_Book_x0020_-_x0020_Remove_x0020_Child_x0020_"; Reference firtItem = sourcePredicate.Items[0] as Reference; Assert.IsTrue(firtItem.path.StartsWith(expectedPath)); } finally { AuthenticationUtils.endSession(); } }
private void btnUpload_Click(object sender, EventArgs e) { try { String file = this.textBox1.Text; if (file.Equals("")) { MessageBox.Show("Please select a file"); this.btnSelect.Focus(); return; } if (this.tbLocation.Text.Equals("")) { MessageBox.Show("Please select the location"); this.btnLocation.Focus(); return; } int start = file.LastIndexOf("\\") + 1; int length = file.Length - start; // get the filename only String fileName = file.Substring(start, length); if (file == null || file.Equals("")) { MessageBox.Show("please select a file"); return; } // Display a wait cursor while the file is uploaded Cursor.Current = Cursors.WaitCursor; // Initialise the reference to the spaces store Alfresco.RepositoryWebService.Store spacesStore = new Alfresco.RepositoryWebService.Store(); spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; spacesStore.address = "SpacesStore"; // Create the parent reference, the company home folder Alfresco.RepositoryWebService.ParentReference parentReference = new Alfresco.RepositoryWebService.ParentReference(); parentReference.store = spacesStore; // parentReference.path = "/app:company_home"; parentReference.uuid = this.locationUuid; parentReference.associationType = Constants.ASSOC_CONTAINS; parentReference.childName = Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, fileName); // Create the properties list NamedValue nameProperty = new NamedValue(); nameProperty.name = Constants.PROP_NAME; nameProperty.value = fileName; nameProperty.isMultiValue = false; NamedValue[] properties = new NamedValue[2]; properties[0] = nameProperty; nameProperty = new NamedValue(); nameProperty.name = Constants.PROP_TITLE; nameProperty.value = fileName; nameProperty.isMultiValue = false; properties[1] = nameProperty; // Create the CML create object CMLCreate create = new CMLCreate(); create.parent = parentReference; create.id = "1"; create.type = Constants.TYPE_CONTENT; create.property = properties; // Create and execute the cml statement CML cml = new CML(); cml.create = new CMLCreate[] { create }; UpdateResult[] updateResult = repoService.update(cml); // work around to cast Alfresco.RepositoryWebService.Reference to // Alfresco.ContentWebService.Reference Alfresco.RepositoryWebService.Reference rwsRef = updateResult[0].destination; Alfresco.ContentWebService.Reference newContentNode = new Alfresco.ContentWebService.Reference(); newContentNode.path = rwsRef.path; newContentNode.uuid = rwsRef.uuid; Alfresco.ContentWebService.Store cwsStore = new Alfresco.ContentWebService.Store(); cwsStore.address = "SpacesStore"; spacesStore.scheme = Alfresco.RepositoryWebService.StoreEnum.workspace; newContentNode.store = cwsStore; // Open the file and convert to byte array FileStream inputStream = new FileStream(file, FileMode.Open); int bufferSize = (int)inputStream.Length; byte[] bytes = new byte[bufferSize]; inputStream.Read(bytes, 0, bufferSize); inputStream.Close(); Alfresco.ContentWebService.ContentFormat contentFormat = new Alfresco.ContentWebService.ContentFormat(); contentFormat.mimetype = mimeType.GuessMimetype(file); WebServiceFactory.getContentService().write(newContentNode, Constants.PROP_CONTENT, bytes, contentFormat); // Reset the cursor to the default for all controls. Cursor.Current = Cursors.Default; MessageBox.Show(file + " uploaded"); } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); MessageBox.Show(ex.StackTrace); } }
public void CanCreateNodesWithContent() { AuthenticationUtils.startSession("admin", "admin"); Store spacesStore = new Store(StoreEnum.workspace, "SpacesStore"); String name = "AWSBook " + DateTime.Now.Ticks; String description = "This is a content created with a sample of the book"; String mimeType = "text/plain"; String encoding = "UTF-8"; //custom value object CreateSampleVO createSampleVo = Builder.BuildCreateSampleVO(name, name, description); try { ParentReference parent = new ParentReference( spacesStore, null, "/app:company_home", Constants.ASSOC_CONTAINS, "{" + Constants.NAMESPACE_CONTENT_MODEL + "}" + name ); //build properties NamedValue[] properties = Builder.BuildCustomProperties(createSampleVo); //create operation CMLCreate create = new CMLCreate(); create.id = "1"; create.parent = parent; create.type = Constants.TYPE_CONTENT; create.property = properties; //create the node reference Reference reference = new Reference(); reference.store = spacesStore; reference.path = "/app:company_home/cm:" + ISO9075.Encode(name); //create the predicate Predicate predicate = new Predicate(); predicate.Items = new Reference[]{ reference }; //set mime type and encoding for indexing ContentFormat format = new ContentFormat(mimeType, encoding); //write operation CMLWriteContent writeContent = new CMLWriteContent(); writeContent.format = format; writeContent.where = predicate; writeContent.property = Constants.PROP_CONTENT; writeContent.content = new ASCIIEncoding().GetBytes("This is the content for the new node"); //build the CML object CML cml = new CML(); cml.create = new CMLCreate[]{ create }; cml.writeContent = new CMLWriteContent[]{ writeContent }; //perform a complete CML update for the node and the related file UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cml); String expectedPath = "/app:company_home/cm:AWSBook_x0020_"; Assert.IsTrue(result[0].destination.path.StartsWith(expectedPath)); } finally { AuthenticationUtils.endSession(); } }
private void button2_Click(object sender, EventArgs e) { Alfresco.RepositoryWebService.Store[] stores = this.repoService.getStores(); Alfresco.RepositoryWebService.Store vStore = stores[3]; 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 { } } } }