Java Code Examples for org.apache.chemistry.opencmis.client.api.Folder#createFolder()
The following examples show how to use
org.apache.chemistry.opencmis.client.api.Folder#createFolder() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SampleClient.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * Create test folder directly under target folder * * @param target * @param createFolderName * @return newly created folder */ private static Folder createFolder(Folder target, String newFolderName) { Map<String, String> props = new HashMap<String, String>(); props.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); props.put(PropertyIds.NAME, newFolderName); Folder newFolder = target.createFolder(props); return newFolder; }
Example 2
Source File: OpenCmisLocalTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void DISABLED_testBasicFileOps() { Repository repository = getRepository("admin", "admin"); Session session = repository.createSession(); Folder rootFolder = session.getRootFolder(); // create folder Map<String,String> folderProps = new HashMap<String, String>(); { folderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); folderProps.put(PropertyIds.NAME, getName() + "-" + GUID.generate()); } Folder folder = rootFolder.createFolder(folderProps, null, null, null, session.getDefaultContext()); Map<String, String> fileProps = new HashMap<String, String>(); { fileProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document"); fileProps.put(PropertyIds.NAME, "mydoc-" + GUID.generate() + ".txt"); } ContentStreamImpl fileContent = new ContentStreamImpl(); { ContentWriter writer = new FileContentWriter(TempFileProvider.createTempFile(getName(), ".txt")); writer.putContent("Ipsum and so on"); ContentReader reader = writer.getReader(); fileContent.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN); fileContent.setStream(reader.getContentInputStream()); } folder.createDocument(fileProps, fileContent, VersioningState.MAJOR); }
Example 3
Source File: CMISDataCreatorTest.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
public void testCreate() { Session session = getSession("admin", "admin"); String folderName = getRootFolderName(); Folder root = session.getRootFolder(); Map<String, Object> properties = new HashMap<String, Object>(); properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); properties.put(PropertyIds.NAME, folderName); // create the folder Folder newFolder = root.createFolder(properties); for(int i = 0; i < 50; i++) { AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl("user"+i); List<String> permissions = new ArrayList<String>(1); permissions.add(BasicPermissions.READ); List<Ace> addAces = new ArrayList<Ace>(1); addAces.add(new AccessControlEntryImpl(principal, permissions)); newFolder.addAcl(addAces, AclPropagation.PROPAGATE); Map<String, Object> updateProperties = new HashMap<String, Object>(); updateProperties.put("cm:title", "Update title "+i); newFolder.updateProperties(properties); if(i % 10 == 0) { System.out.println("@ "+i); } } ItemIterable<QueryResult> result = session.query("select * from cmis:folder", false); assertTrue(result.getTotalNumItems() > 0); result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false); assertTrue(result.getTotalNumItems() > 0); }
Example 4
Source File: TestRemovePermissions.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
/** * * @param session Session * @param name String * @return Folder */ private Folder createFolder(Session session, String name) { Folder testFolder; Folder folder = session.getRootFolder(); Map<String, Object> properties = new HashMap<String, Object>(); properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); properties.put(PropertyIds.NAME, name); testFolder = folder.createFolder(properties); return testFolder; }
Example 5
Source File: PublicApiClient.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public Folder createFolder(String folderId, String name, Map<String, Serializable> properties) { CmisObject o = getObject(folderId); if(o instanceof Folder) { Folder f = (Folder)o; if(properties == null) { properties = new HashMap<String, Serializable>(); } String objectTypeId = (String)properties.get(PropertyIds.OBJECT_TYPE_ID); String type = "cmis:folder"; if(objectTypeId == null) { objectTypeId = type; } if(objectTypeId.indexOf(type) == -1) { StringBuilder sb = new StringBuilder(objectTypeId); if(sb.length() > 0) { sb.append(","); } sb.append(type); objectTypeId = sb.toString(); } properties.put(PropertyIds.NAME, name); properties.put(PropertyIds.OBJECT_TYPE_ID, objectTypeId); Folder res = f.createFolder(properties); return res; } else { throw new IllegalArgumentException("Parent does not exist or is not a folder"); } }
Example 6
Source File: CMISDataCreatorTest.java From SearchServices with GNU Lesser General Public License v3.0 | 4 votes |
public void testCreateLots() throws Exception { Session session = getSession("admin", "admin"); Folder root = session.getRootFolder(); String folderNameBase = getRootFolderName(); Map<String, Object> properties = new HashMap<String, Object>(); properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); properties.put(PropertyIds.NAME, folderNameBase); Folder base = root.createFolder(properties); for(int i = 0; i < 10; i++) { AccessControlPrincipalDataImpl principal = new AccessControlPrincipalDataImpl(""+i+i+i); List<String> permissions = new ArrayList<String>(1); permissions.add(BasicPermissions.ALL); List<Ace> addAces = new ArrayList<Ace>(1); addAces.add(new AccessControlEntryImpl(principal, permissions)); base.addAcl(addAces, AclPropagation.PROPAGATE); } Thread last = null; for(int i = 0; i < 10; i++) { Creator creator = new Creator(base.getPath(), i); Thread thread = new Thread(creator); thread.start(); last = thread; } if(last != null) { last.join(); } ItemIterable<QueryResult> result = session.query("select * from cmis:folder", false); assertTrue(result.getTotalNumItems() > 0); //result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false); //assertTrue(result.getTotalNumItems() > 0); }
Example 7
Source File: CMISDataCreatorTest.java From SearchServices with GNU Lesser General Public License v3.0 | 4 votes |
public void testQueryFolderProperties() { Session session = getSession("admin", "admin"); String folderName = getRootFolderName(); Folder root = session.getRootFolder(); Map<String, Object> properties = new HashMap<String, Object>(); properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); properties.put(PropertyIds.NAME, folderName); // create the folder Folder newFolder = root.createFolder(properties); ItemIterable<QueryResult> result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false); assertEquals(1, result.getTotalNumItems()); String uniqueName = getUniqueName(); Map<String, Object> uProperties = new HashMap<String, Object>(); uProperties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); uProperties.put(PropertyIds.NAME, uniqueName); Folder uniqueFolder = newFolder.createFolder(uProperties); result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"'", false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND IN_FOLDER('"+ uniqueFolder.getParentId() + "')" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:folder where IN_FOLDER('"+ uniqueFolder.getParentId() + "')" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:createdBy = '"+ uniqueFolder.getCreatedBy()+"'" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:objectId = '"+ uniqueFolder.getId()+"'" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:lastModifiedBy = '"+ uniqueFolder.getLastModifiedBy()+"'" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:folder where cmis:name = '"+ uniqueFolder.getName()+"'" , false); assertEquals(1, result.getTotalNumItems()); String creationDate = ISO8601DateFormat.format(uniqueFolder.getCreationDate().getTime()); result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:creationDate = '"+ creationDate +"'" , false); assertEquals(1, result.getTotalNumItems()); String modificationDate = ISO8601DateFormat.format(uniqueFolder.getLastModificationDate().getTime()); result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:lastModificationDate = '"+ modificationDate+"'" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:objectTypeId = '"+ uniqueFolder.getType().getQueryName()+"'" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:folder where cmis:name = '"+uniqueName+"' AND cmis:baseTypeId = '"+ uniqueFolder.getBaseType().getQueryName()+"'" , false); assertEquals(1, result.getTotalNumItems()); }
Example 8
Source File: CMISDataCreatorTest.java From SearchServices with GNU Lesser General Public License v3.0 | 4 votes |
public void testQueryDocumentProperties() throws Exception { Session session = getSession("admin", "admin"); String folderName = getRootFolderName(); Folder root = session.getRootFolder(); Map<String, Object> properties = new HashMap<String, Object>(); properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); properties.put(PropertyIds.NAME, folderName); // create the folder Folder newFolder = root.createFolder(properties); ItemIterable<QueryResult> result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false); assertEquals(1, result.getTotalNumItems()); Document uniqueDocument = createUniqueDocument(newFolder); result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"'", false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND IN_FOLDER('"+ newFolder.getId() + "')" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:document where IN_FOLDER('"+ newFolder.getId() + "')" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:createdBy = '"+ uniqueDocument.getCreatedBy()+"'" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:objectId = '"+ uniqueDocument.getId()+"'" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:lastModifiedBy = '"+ uniqueDocument.getLastModifiedBy()+"'" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:document where cmis:name = '"+ uniqueDocument.getName()+"'" , false); assertEquals(1, result.getTotalNumItems()); String creationDate = ISO8601DateFormat.format(uniqueDocument.getCreationDate().getTime()); result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:creationDate = '"+ creationDate +"'" , false); assertEquals(1, result.getTotalNumItems()); String modificationDate = ISO8601DateFormat.format(uniqueDocument.getLastModificationDate().getTime()); result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:lastModificationDate = '"+ modificationDate+"'" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:objectTypeId = '"+ uniqueDocument.getType().getQueryName()+"'" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:baseTypeId = '"+ uniqueDocument.getBaseType().getQueryName()+"'" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:contentStreamFileName = '"+ uniqueDocument.getContentStreamFileName()+"'" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:contentStreamLength = '"+ uniqueDocument.getContentStreamLength()+"'" , false); assertEquals(1, result.getTotalNumItems()); result = session.query("select * from cmis:document where cmis:name = '"+uniqueDocument.getName()+"' AND cmis:contentStreamMimeType = '"+ uniqueDocument.getContentStreamMimeType()+"'" , false); assertEquals(1, result.getTotalNumItems()); }
Example 9
Source File: CMISDataCreatorTest.java From SearchServices with GNU Lesser General Public License v3.0 | 4 votes |
public void testQueryForMultipleDocumentProperties() throws Exception { Session session = getSession("admin", "admin"); String folderName = getRootFolderName(); Folder root = session.getRootFolder(); Map<String, Object> properties = new HashMap<String, Object>(); properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); properties.put(PropertyIds.NAME, folderName); // create the folder Folder newFolder = root.createFolder(properties); ItemIterable<QueryResult> result = session.query("select * from cmis:folder where cmis:name = '"+folderName+"'", false); assertEquals(1, result.getTotalNumItems()); Document document1 = createUniqueDocument(newFolder); Document document2 = createUniqueDocument(newFolder); //result = session.query("SELECT * FROM cmis:folder d join sys:hidden t on d.cmis:objectId = t.cmis:objectId", false); //assertTrue(0 < result.getTotalNumItems()); //result = session.query("SELECT * FROM cmis:folder d join sys:hidden t on d.cmis:objectId = t.cmis:objectId where t.sys:cascadeHidden = false", false); //assertTrue(0 < result.getTotalNumItems()); result = session.query("SELECT * FROM cmis:document d join exif:exif t on d.cmis:objectId = t.cmis:objectId", false); long count = result.getTotalNumItems(); Map<String, Object> props = new HashMap<String, Object>(); props.put("exif:focalLength", 10.33d); ArrayList<String> aspects = new ArrayList<String>(); aspects.add("P:exif:exif"); props.put("cmis:secondaryObjectTypeIds", aspects); document1.updateProperties(props); result = session.query("SELECT * FROM cmis:document d join exif:exif t on d.cmis:objectId = t.cmis:objectId", false); assertEquals(count+1, result.getTotalNumItems()); result = session.query("select * from cmis:document where cmis:name = '"+document1.getName()+"' OR cmis:name = '"+document2.getName()+"'", false); assertEquals(2, result.getTotalNumItems()); result = session.query("select * from cmis:document where cmis:name = '"+document1.getName()+"' AND cmis:contentStreamLength = 5 AND cmis:contentStreamMimeType = 'text/plain'", false); assertEquals(1, result.getTotalNumItems()); result = session.query("SELECT * FROM cmis:document", false); long docCount = result.getTotalNumItems(); result = session.query("SELECT * FROM cmis:document d left outer join exif:exif t on d.cmis:objectId = t.cmis:objectId", false); assertEquals(docCount, result.getTotalNumItems()); }
Example 10
Source File: CmisIntegrationTest.java From wildfly-camel with Apache License 2.0 | 4 votes |
private Folder createChildFolderWithName(Folder parent, String childName) { Map<String, Object> properties = new HashMap<>(); properties.put(PropertyIds.OBJECT_TYPE_ID, CamelCMISConstants.CMIS_FOLDER); properties.put(PropertyIds.NAME, childName); return parent.createFolder(properties); }