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 ResultSetRow FindNodeByPath(ref string nodePath) { ResultSetRow lResult = null; nodePath = PathUtils.NormalicePath(nodePath); string queryString = PathUtils.ConvertToRepositoryPath(System.IO.Path.GetDirectoryName(nodePath) + "/" + ISO9075.Encode(System.IO.Path.GetFileName(nodePath))); var query = new RepositoryWebService.Query(); query.language = Constants.QUERY_LANG_LUCENE; //TODO: Consultas que sí funcionan: //query.statement = "PATH:\"//app:company_home//cm:Pruebas//cm:Test_Folder/*\""; //query.statement = "PATH:\"//cm:Pruebas//cm:Test_Folder/*\""; Todos los archivos de un folder //query.statement = "PATH:\"//cm:Pruebas//cm:Test_Folder\""; Devuelve un folder query.statement = "PATH:\"" + queryString + "\""; QueryResult result = WebServiceFactory.getRepositoryService().query(spacesStore, query, false); if (result.resultSet.rows != null) { lResult = result.resultSet.rows[0]; } return(lResult); }