private int countChildren(Folder folder) { int count = 0; ItemIterable<CmisObject> children = folder.getChildren(SELECT_ALL_NO_CACHE_OC); for (CmisObject child : children) { if (child instanceof Folder) { count++; } } return count; } }
private int countChildren(Folder folder) { int count = 0; ItemIterable<CmisObject> children = folder.getChildren(SELECT_ALL_NO_CACHE_OC); for (CmisObject child : children) { if (child instanceof Document) { count++; } } return count; } }
/** * Counts the children in a folder. */ protected int countFolderChildren(Folder folder) { int count = 0; for (@SuppressWarnings("unused") CmisObject object : folder.getChildren()) { count++; } return count; }
Folder currentFolder = root; Folder parentFolder = null; for(int i=0;i<folderNamesLength; i++){ // because root is folderNames[i] String folderName = folderNames[i]; int currentFolderSize = currentFolder.getChildren.getSize(); for(int o=1; o<currentFolderSize ; o++){ if(currentFolder.getChildren().get(o) instanceof Folder){ Folder childFolder = currentFolder.getChildren().get(o); if(folderName.equals(childFolder.getFolderName())){ parentFolder = currentFolder; currentFolder = childFolder; if (i == counter){ currentFolder.getChildren.add(newFolder); // reorganize parentFolder.getChildren() or whatever } } } } }
@Override public Collection<String> validateData(BpmTask task, boolean skipRequired) { if (required && !mainFolder.getChildren().iterator().hasNext()) { return Arrays.asList("pt.ext.cmis.list.document.validate.upload.document"); } else { return null; } }
public void printFolderRecursively(Folder folder) { System.out.print("/" + rootFolderName); for(Folder child : folder.getChildren()) printFolderRecursively(child); }
/** * look for a child folder of the parent folder, if not found, create it and return it. */ private static Folder getOrCreateFolder(final Folder parentFolder, final String folderName) throws IOException { Folder childFolder = null; // get existing if any ItemIterable<CmisObject> children = parentFolder.getChildren(); if (children.iterator().hasNext()) { for (CmisObject cmisObject : children) { if (cmisObject instanceof Folder && cmisObject.getName().equals(folderName)) { log.debug("Found '{}' folder.", folderName); return childFolder = (Folder)cmisObject; } } } // Create new folder (requires at least type id and name of the folder) log.debug("'{}' folder not found, about to create...", folderName); Map<String, String> folderProps = new HashMap<String, String>(); folderProps.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); folderProps.put(PropertyIds.NAME, folderName); childFolder = parentFolder.createFolder(folderProps); log.info("'{}' folder created!", folderName); return childFolder; }
/** * Converts CMIS folder children to JCR node children * * @param folder CMIS folder * @param writer JCR node representation */ private void cmisChildren( Folder folder, DocumentWriter writer ) { ItemIterable<CmisObject> it = folder.getChildren(); for (CmisObject obj : it) { writer.addChild(obj.getId(), obj.getName()); } }
@Override public List<CMSContentSummary> getChildren(String id) { Session session = getSession(); if (session != null) { Folder folder = null; if (id == null || id.isEmpty()) { folder = session.getRootFolder(); } else { folder = (Folder) session.getObject(id); } ItemIterable<CmisObject> children = folder.getChildren(); Iterator<CmisObject> childrenItems = children.iterator(); List<CmisObject> documents = new ArrayList<CmisObject>(); while (childrenItems.hasNext()) { CmisObject item = childrenItems.next(); documents.add(item); } return this.transform(documents, folder); } return new ArrayList<CMSContentSummary>(); }
public ItemIterable<CmisObject> getChildren(String networkId, String folderId, int skipCount, int maxItems, IncludeRelationships includeRelationships, Boolean includeAcls, Set<String> propertyFilter, Boolean includePolicies) { CMISEndpoint cmisEndpoint = new CMISEndpoint(BindingType.BROWSER, CmisVersion.CMIS_1_1); Session session = getCMISSession(networkId, cmisEndpoint); CmisObject o = session.getObject(folderId); if (o instanceof Folder) { Folder f = (Folder) o; ItemIterable<CmisObject> res = f.getChildren(cmisOperationContext); res.skipTo(skipCount); ItemIterable<CmisObject> ret = res.getPage(maxItems); return ret; } else { throw new IllegalArgumentException( "Folder does not exist or is not a folder"); } }
ItemIterable<CmisObject> children = folder.getChildren(); if (children.iterator().hasNext()) { for (CmisObject o : children) {
public ObjectId createFolder(String folderName, String parentObjectId) { ObjectId returnId = null; Session session = this.getSession(this.connectionParameters); if (session != null) { if (StringUtils.isEmpty(parentObjectId)) { parentObjectId = session.getRootFolder().getId(); } Map<String, Object> properties = new HashMap<String, Object>(); properties.put(PropertyIds.NAME, folderName); properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder"); try { returnId = session.createFolder(properties, session.getObject(session.createObjectId(parentObjectId))); } catch (CmisContentAlreadyExistsException e) { logger.debug("CMIS Content Already Exists ", e); CmisObject object = session.getObject(session.createObjectId(parentObjectId)); if (!(object instanceof Folder)) { throw new IllegalArgumentException(parentObjectId + " is not a folder"); } Folder folder = (Folder) object; for (CmisObject o : folder.getChildren()) { if (o.getName().equals(folderName)) { return session.createObjectId(o.getId()); } } } } return returnId; // End createFolder }
FileVisitResult walk(Folder start) throws IOException { FileVisitResult preVisitDirectoryResult = visitor.preVisitDirectory(start, null); if (preVisitDirectoryResult != FileVisitResult.CONTINUE) { return preVisitDirectoryResult; } ItemIterable<CmisObject> children = start.getChildren(); if (children.iterator().hasNext()) { for (CmisObject o : children) { if (o instanceof Folder) { FileVisitResult childFolderWalkResult = walk((Folder)o); // returning null will cause NPE to be thrown if (childFolderWalkResult == null || childFolderWalkResult == FileVisitResult.TERMINATE) return childFolderWalkResult; // skip remaining siblings in this directory if (childFolderWalkResult == FileVisitResult.SKIP_SIBLINGS) break; } else if (o instanceof Document) { FileVisitResult visitFileResult = visitor.visitFile(o, null); // returning null will cause NPE to be thrown if (visitFileResult == null || visitFileResult == FileVisitResult.TERMINATE) return visitFileResult; // skip remaining siblings in this directory if (visitFileResult == FileVisitResult.SKIP_SIBLINGS) break; } } } return visitor.postVisitDirectory(start, null); } }
for (CmisObject child : folder.getChildren(SELECT_ALL_NO_CACHE_OC)) { children.add(child);
ItemIterable<CmisObject> children = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC); List<String> childrenIds = new ArrayList<String>(); for (CmisObject child : children) {
public Object folder(Folder folder, String folderId, NavigationOptions get, Integer depth, String filter, String orderBy) { validateObjectOrId(folder, folderId); validateRedundantIdentifier(folder, folderId); Folder target = getCmisObject(folder, folderId, Folder.class); Object ret = null; if (target != null) { if (get.equals(NavigationOptions.DESCENDANTS) || get.equals(NavigationOptions.TREE)) { Validate.notNull(depth, "depth is null"); } if (get.equals(NavigationOptions.PARENT)) { ret = target.getFolderParent(); } else { OperationContext ctx = createOperationContext(filter, orderBy); if (get.equals(NavigationOptions.CHILDREN)) { ret = target.getChildren(ctx); } else if (get.equals(NavigationOptions.DESCENDANTS)) { ret = target.getDescendants(depth, ctx); } else if (get.equals(NavigationOptions.TREE)) { ret = target.getFolderTree(depth, ctx); } } } return ret; }
ItemIterable<CmisObject> children = testFolder.getChildren(SELECT_ALL_NO_CACHE_OC); List<String> childrenIds = new ArrayList<String>(); for (CmisObject child : children) {
private Component getDocumentList() { VerticalLayout vl = new VerticalLayout(); vl.setWidth("100%"); ItemIterable<CmisObject> cmisObjectItemIterable = mainFolder.getChildren(); boolean hasAnyDocuments = false; for (CmisObject co : cmisObjectItemIterable) {
for (CmisObject child : testFolder.getChildren(context)) { if (child.getId().equals(testDocument.getId())) {
ItemIterable<CmisObject> children = folder.getChildren(orderContext);