public void _updateAchievements(CML response) { //get the complete list of awarded achievements string [] unlocked = response [0].String("unlocked").Split(','); if (unlocked.Length == 0) { return; } WUAView [] views = FindObjectsOfType <WUAView>(); //scan through all unlocked achievements foreach (string aid in unlocked) { foreach (WUAView view in views) { if (view.Fields.String("aid") == aid) { //inside the gui object we linked the object to this achievement data block //so work backwards and use the data block to determine which gui object to work on view.Unlocked = true; view.DisplayRelevantVersion(); } } } }
private CML getCMLCreate(NamedValue[] properties) { string qName = "ASCENT_" + releaseData.UniqueDocumentID.ToString(); // get the parent reference Alfresco.RepositoryWebService.ParentReference parentReference = new Alfresco.RepositoryWebService.ParentReference(); parentReference.store = spacesStore; parentReference.uuid = this.locationUuid; parentReference.associationType = Constants.ASSOC_CONTAINS; // set node content type parentReference.childName = this.contentType; // Create the CML create object CMLCreate create = new CMLCreate(); create.parent = parentReference; create.id = "1"; // set the contenttype create.type = this.contentType; create.property = properties; // Create and execute the cml statement CML cml = new CML(); cml.create = new CMLCreate[] { create }; return(cml); }
protected UpdateResult[] CreateNode(string parentId, string parentPath, string nodeType) { UpdateResult[] result = null; var parent = new RepositoryWebService.ParentReference( spacesStore, parentId, parentPath, Constants.ASSOC_CONTAINS, Constants.createQNameString(Constants.NAMESPACE_CONTENT_MODEL, name) ); //build properties BuildCustomProperties(); //create operation CMLCreate create = new CMLCreate(); create.id = "1"; create.parent = parent; create.type = nodeType; // 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 result = WebServiceFactory.getRepositoryService().update(cml); return(result); }
async void GenerateEntries(CML response = null) { float now = Time.time; //in case we just logged in now and this function gets called before WUAchievementManager had a chance to run... while (null == WUAchieveManager.Instance.all_awards || WUAchieveManager.Instance.all_awards.Count == 0 || null == WUAchieveManager.Instance.Keys || WUAchieveManager.Instance.Keys.Count == 0) { await Task.Delay(50); if (Time.time > now + 10f) { Debug.LogError("FAILED TO FIND AWARDS"); return; } } //extract the achievements to work with in this function List <CMLData> entries = WUAchieveManager.Instance.all_awards.Children(0); //make sure our scroll region can handle all the entries... GridLayoutGroup glg = content_area.GetComponent <GridLayoutGroup>(); content_area.sizeDelta = new Vector2(content_area.sizeDelta.x, entries.Count * (view_prefab.GetComponent <RectTransform>().sizeDelta.y + glg.spacing.y)); content_area.sizeDelta = new Vector2(content_area.sizeDelta.x, entries.Count * (glg.cellSize.y + glg.spacing.y)); //and now spawn them... foreach (CMLData entry in entries) { WUAView view = Instantiate(view_prefab); view.transform.SetParent(content_area, false); view.Fields = entry; view.Initialize(); } }
public void CanDeleteNodes() { 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 cmlAdd = new CML(); cmlAdd.create = new CMLCreate[] { create }; //perform a CML update to create the node UpdateResult[] result = WebServiceFactory.getRepositoryService().update(cmlAdd); String expectedPath = "/app:company_home/cm:AWS_x0020_Book_x0020_"; Assert.IsTrue(result[0].destination.path.StartsWith(expectedPath)); //create a predicate Reference reference = result[0].destination; Predicate predicate = new Predicate(new Reference[] { reference }, spacesStore, null); //delete content CMLDelete delete = new CMLDelete(); delete.where = predicate; CML cmlRemove = new CML(); cmlRemove.delete = new CMLDelete[] { delete }; //perform a CML update to remove the node WebServiceFactory.getRepositoryService().update(cmlRemove); expectedPath = "/app:company_home/cm:AWS_x0020_Book_x0020_"; Assert.IsTrue(reference.path.StartsWith(expectedPath)); } finally { AuthenticationUtils.endSession(); } }
///// <summary> ///// Copia un archivo de una localización a otroa ///// </summary> ///// <param name="uuidNodeToCopy"></param> ///// <param name="DestinationNodePath"></param> ///// <returns>En DestinationNodePath se devuelve la ruta final del archivo</returns> //public string CopyFile(string uuidNodeToCopy, ref string DestinationNodePath) //{ // if (string.IsNullOrEmpty(uuidNodeToCopy) || string.IsNullOrEmpty(DestinationNodePath)) // return null; // string documentId = null; // RepositoryWebService.Store cwsStore = new RepositoryWebService.Store(); // cwsStore.address = Constants.SPACES_STORE; // try // { // //Obtenemos la ruta donde se copiara el documento, o la creamos si no existe // FolderNode nod = new FolderNode(); // string destNodeId = nod.CreatePathRecursive(DestinationNodePath); // this.Name = GetNodeById(uuidNodeToCopy).Name; // UpdateResult[] rsrDest = CreateNode(destNodeId, null, Constants.TYPE_CONTENT); // ResultSetRow rsrOrigin = FindNodeById(uuidNodeToCopy); // RepositoryWebService.Reference refOrigin = GetReferenceFromResultSetRow(rsrOrigin); // RepositoryWebService.Predicate sourcePredicate = new RepositoryWebService.Predicate( // new Alfresco.RepositoryWebService.Reference[] { refOrigin }, cwsStore, null); // //reference for the target space // RepositoryWebService.ParentReference targetSpace = new RepositoryWebService.ParentReference(); // targetSpace.store = spacesStore; // targetSpace.path = DestinationNodePath; // targetSpace.associationType = Constants.ASSOC_CONTAINS; // targetSpace.childName = Name; // //copy content // CMLCopy copy = new CMLCopy(); // copy.where = sourcePredicate; // copy.to = targetSpace; // CML cmlCopy = new CML(); // cmlCopy.copy = new CMLCopy[] { copy }; // //perform a CML update to move the node // UpdateResult[] updateResult = WebServiceFactory.getRepositoryService().update(cmlCopy); // DestinationNodePath = ISO9075.Decode(PathUtils.ConvertFromRepositoryPath(updateResult[0].destination.path)); // documentId = updateResult[0].destination.uuid; // } // catch (SoapException ex) // { // if (ex.Detail.InnerText.Contains("DuplicateChildNodeNameException")) // { // var node = new NodeBase(); // var nodePath = String.Format("{0}/{1}", DestinationNodePath, this.Name); // var id = node.GetIdByPath(nodePath); // throw new DuplicateDocumentException(id, nodePath); // } // else // throw ex; // } // catch (Exception ex) // { // throw ex; // } // return documentId; //} //public string CopyFile(string uuidNodeToCopy, ref string DestinationNodePath) //{ // if (string.IsNullOrEmpty(uuidNodeToCopy) || string.IsNullOrEmpty(DestinationNodePath)) // return null; // string documentId = null; // try // { // this.Name = GetNodeById(uuidNodeToCopy).Name; // //Obtenemos la ruta donde se copiara el documento, o la creamos si no existe // FolderNode nod = new FolderNode(); // string destNodeId = nod.CreatePathRecursive(DestinationNodePath); // UpdateResult[] updateNode = CreateNode(destNodeId, null, Constants.TYPE_CONTENT); // //reference for the target space // RepositoryWebService.ParentReference targetSpace = new RepositoryWebService.ParentReference(); // targetSpace.store = spacesStore; // targetSpace.path = updateNode[0].destination.path; // targetSpace.associationType = Constants.ASSOC_CONTAINS; // targetSpace.childName = Name; // RepositoryWebService.Predicate Source = new RepositoryWebService.Predicate( // new Alfresco.RepositoryWebService.Reference[] { GetReferenceFromResultSetRow(FindNodeById(uuidNodeToCopy)) }, spacesStore, null); // //copy content // CMLCopy copy = new CMLCopy(); // copy.where = Source; // copy.to = targetSpace; // CML cmlCopy = new CML(); // cmlCopy.copy = new CMLCopy[] { copy }; // //perform a CML update to move the node // RepositoryWebService.UpdateResult[] updateResult = WebServiceFactory.getRepositoryService().update(cmlCopy); // DestinationNodePath = ISO9075.Decode(PathUtils.ConvertFromRepositoryPath(updateResult[0].destination.path)); // documentId = updateResult[0].destination.uuid; // } // catch (SoapException ex) // { // if (ex.Detail.InnerText.Contains("DuplicateChildNodeNameException")) // { // var node = new NodeBase(); // var nodePath = String.Format("{0}/{1}", DestinationNodePath, this.Name); // var id = node.GetIdByPath(nodePath); // throw new DuplicateDocumentException(id, nodePath); // } // else // throw ex; // } // catch (Exception ex) // { // throw ex; // } // return documentId; //} public string CopyFile(string uuidNodeToCopy, ref string DestinationNodePath) { if (string.IsNullOrEmpty(uuidNodeToCopy) || string.IsNullOrEmpty(DestinationNodePath)) { return(null); } string documentId = null; try { this.Name = GetNodeById(uuidNodeToCopy).Name; //Obtenemos la ruta donde se copiara el documento, o la creamos si no existe FolderNode nod = new FolderNode(); string destNodeId = nod.CreatePathRecursive(DestinationNodePath); RepositoryWebService.Predicate Source = new RepositoryWebService.Predicate( new Alfresco.RepositoryWebService.Reference[] { GetReferenceFromResultSetRow(FindNodeById(uuidNodeToCopy)) }, spacesStore, null); //copy content CMLCopy copy = new CMLCopy(); copy.where = Source; copy.to = createParentReference(destNodeId, Constants.ASSOC_CONTAINS, Name); CML cmlCopy = new CML(); cmlCopy.copy = new CMLCopy[] { copy }; //perform a CML update to move the node RepositoryWebService.UpdateResult[] updateResult = WebServiceFactory.getRepositoryService().update(cmlCopy); DestinationNodePath = ISO9075.Decode(PathUtils.ConvertFromRepositoryPath(updateResult[0].destination.path)); documentId = updateResult[0].destination.uuid; } catch (SoapException ex) { if (ex.Detail.InnerText.Contains("DuplicateChildNodeNameException")) { var node = new NodeBase(); var nodePath = String.Format("{0}/{1}", DestinationNodePath, this.Name); var id = node.GetIdByPath(nodePath); throw new DuplicateDocumentException(id, nodePath); } else { throw ex; } } catch (Exception ex) { throw ex; } return(documentId); }
void HideAvatar(CML response = null) { SetGravatar(); high_score_text.gameObject.SetActive(false); username_text.gameObject.SetActive(false); heart.gameObject.SetActive(false); coins.gameObject.SetActive(false); coins_text.gameObject.SetActive(false); lives_text.gameObject.SetActive(false); }
private void deleteReference(Alfresco.RepositoryWebService.Reference reference) { Alfresco.RepositoryWebService.Predicate where = new Alfresco.RepositoryWebService.Predicate(); where.Items = new Alfresco.RepositoryWebService.Reference[] { reference }; CMLDelete cmlDelete = new CMLDelete(); cmlDelete.where = where; CML cml = new CML(); cml.delete = new CMLDelete[] { cmlDelete }; this.repoService.update(cml); }
private void DeleteNodes(Alfresco.RepositoryWebService.Reference[] references) { var predicate = new RepositoryWebService.Predicate(references, spacesStore, null); //delete content CMLDelete delete = new CMLDelete(); delete.where = predicate; CML cmlRemove = new CML(); cmlRemove.delete = new CMLDelete[] { delete }; //perform a CML update to remove the node WebServiceFactory.getRepositoryService().update(cmlRemove); }
//NOTE: Possible exploit! User can play on multiple devices at once and if the price is set to 100 on all devices then a check to see if //the user has 100 currency and based on that the level is upgraded by 1 means they can upgrade to max and only pay the lowest price for each //upgrade level. The correct course of action would be to first fetch the inventory again, check what the current level is of whatever is being //upgraded, make sure the current cost is the correct cost for the item being purchased (updating the GUI if not the case) and only then attempt //to buy the item. //When dealing with money this would be the safest course of action but since this is just a demo made for a fun passtime I am not being that strict void _updateAmmo(CML response) { //see what was already stored online and add one. Make sure you don't exceed the max level or you'll get array index out of bounds errors WeaponInstance weapon = Ammo [temp_storage.x]; int new_value = Mathf.Min(weapon.MaxAmmo, weapon.Ammo + temp_storage.y); //update the value locally so we can play then update it online for future games also CMLData update = new CMLData(); update.Seti(weapon.Weapon.WeaponName, new_value); Stock.Seti(weapon.Weapon.WeaponName, new_value); WUData.UpdateCategory(category_name_inventory, update); //display a notification of a successful purchase MBSNotification.SpawnInstance(FindObjectOfType <Canvas>(), new Vector2(200f, -50f), new Vector2(0f, -50f), "Purchase Successful", $"You now have {Stock.Int(weapon.Weapon.WeaponName)} {weapon.Weapon.WeaponName}s", weapon.Weapon.Icon); }
void ParseUserData(CML response) { //make sure there is set data. If the WUData demo was run first and the GameID has not yet been changed //we might be getting back a bunch of settings that doesn't incldue this game's settings... if (response.Count < 4 || null == response.NodesWithField("category", category_name_inventory)) { WelcomeFirstTimePlayer(); } else { //WUMoney.AwardCurrency( 1000, "dust" ); Settings = response.NodeWithField("category", category_name_settings) ?? new CMLData(); Unlocked = response.NodeWithField("category", category_name_unlocked) ?? new CMLData(); Stock = response.NodeWithField("category", category_name_inventory) ?? new CMLData(); AmmoLevels = response.NodeWithField("category", category_name_max_ammo) ?? new CMLData(); DamageLevels = response.NodeWithField("category", category_name_max_damage) ?? new CMLData(); RangeLevels = response.NodeWithField("category", category_name_max_range) ?? new CMLData(); } menu_tests_passed++; }
private CML getCMLUpdate(String uuid, NamedValue[] properties) { // ************ test ***********8 /* * for (int i = 0; i < properties.Length; i++) * { * * NamedValue name = properties[i]; * if (name.name.Equals(Alfresco.Constants.PROP_DESCRIPTION)) * { * MessageBox.Show("Gotcha"); * name.value = "UPDATE"; * properties[i] = name; * } * } */ Alfresco.RepositoryWebService.Reference reference = new Alfresco.RepositoryWebService.Reference(); reference.store = this.spacesStore; reference.uuid = uuid; CMLUpdate cmlUpdate = new CMLUpdate(); Alfresco.RepositoryWebService.Predicate pred = new Alfresco.RepositoryWebService.Predicate(); pred.Items = new Alfresco.RepositoryWebService.Reference[] { reference }; cmlUpdate.where = pred; cmlUpdate.property = properties; // Create and execute the cml statement CML cml = new CML(); cml.update = new CMLUpdate[] { cmlUpdate }; return(cml); }
void FetchSubscription(CML ignore) => WPServer.ContactServer(WUExpActions.IsSubscribed, filepath, ASSET, null, TestResponse, ( CMLData result ) => Debug.LogWarning(result.String("message"))); //in 2018.1 change CMLData to CMLData void TestResponse(CML response) { has_subsciption = response [0].Bool("subscribed"); OnSubscriptionTested?.Invoke(); }
void FetchSubscription(CML ignore) => WPServer.ContactServer(WUExpActions.IsSubscribed, filepath, ASSET, null, TestResponse, ( CMLData result ) => Debug.LogWarning(result.String("message"))); //in 2018.1 change CMLData to CMLData
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); } }
void OnLoggedOut(CML response) { SavePlayerData(); Stock = AmmoLevels = DamageLevels = RangeLevels = null; }
void FetchUserData(CML response) => WUData.FetchGameInfo(ParseUserData, errorResponse: GenerateFirstTimePlayerData);
void ShowScores(CML response) { WUScoring.onFetched -= ShowScores; scoring.OnFetched(response); }
//fetch all achievements from the server //upon receiving the server response spawn a prefab to display each returned result void FetchAwards(CML response) => WUAchieve.FetchEverything(GenerateEntries, ( CMLData error ) => Debug.LogWarning("--------> Expected data! Make sure there are achievements on your site!"));
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 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(); } }
public void CanRemoveChildNodes() { 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; //add child CMLAddChild addChild = new CMLAddChild(); addChild.where = sourcePredicate; addChild.to = targetSpace; CML cmlAddChild = new CML(); cmlAddChild.addChild = new CMLAddChild[] { addChild }; //perform a CML update to add a child node UpdateResult[] resultAddChild = WebServiceFactory.getRepositoryService().update(cmlAddChild); expectedPath = "/app:company_home/cm:AWS_x0020_Book_x0020_-_x0020_Remove_x0020_Child_x0020_"; Assert.IsTrue(referenceForNode.path.StartsWith(expectedPath)); expectedPath = "/app:company_home/cm:AWS_x0020_Book_x0020_-_x0020_Remove_x0020_Child_x0020_Space_x0020_Sample_x0020_"; Assert.IsTrue(targetSpace.path.StartsWith(expectedPath)); Reference refUpdate = resultAddChild[0].destination; Predicate nodeToRemove = new Predicate(new Reference[] { refUpdate }, spacesStore, null); //remove child CMLRemoveChild removeChild = new CMLRemoveChild(); removeChild.Item = targetSpace; removeChild.where = nodeToRemove; CML cmlRemoveChild = new CML(); cmlRemoveChild.removeChild = new CMLRemoveChild[] { removeChild }; //perform a CML update to remove the node WebServiceFactory.getRepositoryService().update(cmlRemoveChild); expectedPath = "/app:company_home/cm:AWS_x0020_Book_x0020_-_x0020_Remove_x0020_Child_x0020_"; Reference firtsItem = nodeToRemove.Items[0] as Reference; Assert.IsTrue(firtsItem.path.StartsWith(expectedPath)); expectedPath = "/app:company_home/cm:AWS_x0020_Book_x0020_-_x0020_Remove_x0020_Child_x0020_Space_x0020_Sample_x0020_"; Assert.IsTrue(referenceForTargetSpace.path.StartsWith(expectedPath)); } finally { AuthenticationUtils.endSession(); } }
public void CanVersionNodes() { 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); //update node version 1.1 CMLUpdate update11 = new CMLUpdate(); createSampleVo.Name = "1.1 " + name; createSampleVo.Title = "1.1" + name; update11.property = Builder.BuildCustomProperties(createSampleVo); update11.where = sourcePredicate; CML cmlUpdate11 = new CML(); cmlUpdate11.update = new CMLUpdate[] { update11 }; //perform a CML update WebServiceFactory.getRepositoryService().update(cmlUpdate11); Reference firstItem = sourcePredicate.Items[0] as Reference; expectedPath = "/app:company_home/cm:AWS_x0020_Book_x0020_-_x0020_Remove_x0020_Child_x0020_"; Assert.IsTrue(firstItem.path.StartsWith(expectedPath)); //node history: the 1.0 version Alfresco.AuthoringWebService.Reference reference = Alfresco.AuthoringWebService.Reference.From(firstItem); Alfresco.AuthoringWebService.VersionHistory nodeHistory = WebServiceFactory.getAuthoringService().getVersionHistory(reference); Assert.AreEqual(2, nodeHistory.versions.Length); Alfresco.AuthoringWebService.Version latestVersion = nodeHistory.versions[0]; Assert.NotNull(latestVersion.id.uuid); Assert.AreEqual("1.1", latestVersion.label); Assert.AreEqual(DateTime.Now.Date, latestVersion.created.Date); Assert.AreEqual("admin", latestVersion.creator); Alfresco.AuthoringWebService.Version previousVersion = nodeHistory.versions[1]; Assert.NotNull(previousVersion.id.uuid); Assert.AreEqual("1.0", previousVersion.label); Assert.AreEqual(DateTime.Now.Date, previousVersion.created.Date); Assert.AreEqual("admin", previousVersion.creator); } finally { AuthenticationUtils.endSession(); } }
//after login I disable the prefab by default. So wait a frame or so and then show it again void ShowLoggedInMenu(CML response = null) => StartCoroutine(__ShowPostLoginMenu());