List of usage examples for java.util Queue isEmpty
boolean isEmpty();
From source file:org.sakaiproject.nakamura.files.pool.ExportIMSCP.java
private File getZipFile(Manifest manifest, Content content, String poolId, ContentManager contentManager) throws JSONException, IOException, StorageClientException, AccessDeniedException { String resourcesDir = "resources/"; String filename = (String) content.getProperty(FilesConstants.POOLED_CONTENT_FILENAME); filename = filename.replaceAll("/", "_"); File f = File.createTempFile(filename, ".zip"); f.deleteOnExit();//from w w w. ja v a 2 s . co m ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(f)); List<org.sakaiproject.nakamura.cp.Resource> resources = manifest.getResources().getResources(); if (resources == null) { return null; } for (org.sakaiproject.nakamura.cp.Resource resource : resources) { Item item = new Item(); Queue<Item> items = new LinkedList<Item>(); items.addAll(manifest.getOrganizations().getOrganizations().get(0).getItems()); while (!items.isEmpty()) { Item i = items.poll(); if (i.getIdentifierRef() != null && i.getIdentifierRef().equals(resource.getIdentifier())) { item = i; break; } if (i.hasSubItems()) { items.addAll(i.getItems()); } } String title = resource.getIdentifier() + ".html"; String originTitle = title; if (item.getTitle() != null && item.getTitle().length() != 0) { originTitle = item.getTitle() + ".html"; } String page = collectPageContent(content, resource.getIdentifier(), contentManager); page = handlePage(page, contentManager, poolId, zos); page = "<html><head><title>" + originTitle + "</title></head><body>" + page + "</body></html>"; InputStream input = new ByteArrayInputStream(page.getBytes()); ZipEntry zae = new ZipEntry(resourcesDir + title); zos.putNextEntry(zae); IOUtils.copy(input, zos); } String xml = manifest.generateXML(); InputStream input = new ByteArrayInputStream(xml.getBytes()); ZipEntry zae = new ZipEntry("imsmanifest.xml"); zos.putNextEntry(zae); IOUtils.copy(input, zos); zos.close(); return f; }
From source file:org.kuali.rice.krad.uif.element.ValidationMessages.java
/** * Adds all group keys of this component (starting from this component itself) by calling getKeys on each of * its nested group's ValidationMessages and adding them to the list. * * @param keyList/*from w w w .ja va 2s . c o m*/ * @param component */ protected void addNestedGroupKeys(Collection<String> keyList, Component component) { @SuppressWarnings("unchecked") Queue<LifecycleElement> elementQueue = RecycleUtils.getInstance(LinkedList.class); try { elementQueue.addAll(ViewLifecycleUtils.getElementsForLifecycle(component).values()); while (!elementQueue.isEmpty()) { LifecycleElement element = elementQueue.poll(); ValidationMessages ef = null; if (element instanceof ContainerBase) { ef = ((ContainerBase) element).getValidationMessages(); } else if (element instanceof FieldGroup) { ef = ((FieldGroup) element).getGroup().getValidationMessages(); } if (ef != null) { keyList.addAll(ef.getKeys((Component) element)); } elementQueue.addAll(ViewLifecycleUtils.getElementsForLifecycle(element).values()); } } finally { elementQueue.clear(); RecycleUtils.recycle(elementQueue); } }
From source file:com.connection.factory.FtpConnectionApacheLib.java
@Override public List<RemoteFileObject> readAllFilesWalkinPath(String remotePath) { List<RemoteFileObject> willReturnObject = new ArrayList<>(); Queue<RemoteFileObject> directorylist = new LinkedBlockingQueue<>(); RemoteFileObject object = null;//from ww w . ja v a2s . c om object = new FtpApacheFileObject(FileInfoEnum.DIRECTORY); object.setDirectPath(remotePath); directorylist.add(object); try { while (!directorylist.isEmpty()) { object = directorylist.poll(); FTPFile[] fileListTemp = _ftpObj.listFiles(object.getPath()); for (FTPFile each : fileListTemp) { RemoteFileObject objectTemp = null; if (each.isDirectory()) { objectTemp = new FtpApacheFileObject(FileInfoEnum.DIRECTORY); objectTemp.setFileName(each.getName()); objectTemp.setAbsolutePath(object.getPath()); directorylist.add(objectTemp); } else if (each.isFile()) { objectTemp = new FtpApacheFileObject(FileInfoEnum.FILE); objectTemp.setFileName(each.getName()); objectTemp.setAbsolutePath(object.getPath()); objectTemp.setFileSize(each.getSize()); objectTemp.setFileType(); objectTemp.setDate(each.getTimestamp().getTime()); willReturnObject.add(objectTemp); } } object = null; fileListTemp = null; } } catch (IOException ex) { return null; } catch (ConnectionException ex) { } return willReturnObject; }
From source file:com.connection.factory.FtpConnectionApacheLib.java
@Override public void readAllFilesWalkingPathWithListener(FileListener listener, String remotePath) { // List<RemoteFileObject> willReturnObject = new ArrayList<>(); Queue<RemoteFileObject> directorylist = new LinkedBlockingQueue<>(); RemoteFileObject object = null;//from w w w.j a v a 2s . co m object = new FtpApacheFileObject(FileInfoEnum.DIRECTORY); object.setDirectPath(remotePath); directorylist.add(object); try { while (!directorylist.isEmpty()) { object = directorylist.poll(); FTPFile[] fileListTemp = _ftpObj.listFiles(object.getPath()); for (FTPFile each : fileListTemp) { RemoteFileObject objectTemp = null; if (each.isDirectory()) { objectTemp = new FtpApacheFileObject(FileInfoEnum.DIRECTORY); objectTemp.setFileName(each.getName()); objectTemp.setAbsolutePath(object.getPath()); directorylist.add(objectTemp); } else if (each.isFile()) { objectTemp = new FtpApacheFileObject(FileInfoEnum.FILE); objectTemp.setFileName(each.getName()); objectTemp.setAbsolutePath(object.getPath()); objectTemp.setFileSize(each.getSize()); objectTemp.setFileType(); objectTemp.setDate(each.getTimestamp().getTime()); listener.handleRemoteFile(object); } } object = null; fileListTemp = null; } } catch (IOException | ConnectionException ex) { // return null; } // return willReturnObject; // return willReturnObject; }
From source file:de.tbuchloh.kiskis.gui.treeview.TreeView.java
/** * @return gets all the displayed tree nodes *//*from w w w .j a v a2 s . c om*/ protected Collection<MyTreeNode> getAllNodes() { final Queue<MyTreeNode> treeNodes = new LinkedList<MyTreeNode>(); treeNodes.add(getRoot()); final Collection<MyTreeNode> r = new LinkedList<MyTreeNode>(); r.add(getRoot()); while (!treeNodes.isEmpty()) { final MyTreeNode node = treeNodes.poll(); final List<MyTreeNode> children = Collections.list(node.children()); treeNodes.addAll(children); r.addAll(children); } return r; }
From source file:com.github.pierods.ramltoapidocconverter.RAMLToApidocConverter.java
private List<Apidoc.Operation> walkSubresources(Resource rootResource) { List<Apidoc.Operation> operations = new ArrayList<>(); class NameAndResource { public NameAndResource(String name, Resource resource) { this.name = name; this.resource = resource; }//from www .ja va 2s .co m public String name; public Resource resource; } Queue<NameAndResource> bfsAccumulator = new LinkedList<>(); // path is specified only once for the resource. Subpaths will be only specified if parameters (:xxx), see getOperations() bfsAccumulator.add(new NameAndResource("", rootResource)); while (!bfsAccumulator.isEmpty()) { NameAndResource nr = bfsAccumulator.remove(); operations.addAll(getOperations(nr.name, nr.resource)); Map<String, Resource> subresources = nr.resource.getResources(); for (String resourceName : subresources.keySet()) { bfsAccumulator.add(new NameAndResource(nr.name + resourceName, subresources.get(resourceName))); } } operations.sort((operation1, operation2) -> { if (operation1.path == null) { return 1; } if (operation2.path == null) { return -1; } return operation1.path.compareTo(operation2.path); }); return operations; }
From source file:org.eclipse.skalli.core.search.LuceneIndex.java
private List<IndexEntry> indexEntity(T entity) { List<IndexEntry> fields = new LinkedList<IndexEntry>(); Queue<EntityBase> queue = new LinkedList<EntityBase>(); queue.add(entity);//from ww w .j a v a 2s .co m while (!queue.isEmpty()) { EntityBase currentEntity = queue.poll(); for (ExtensionService<?> extensionService : ExtensionServices.getAll()) { if (currentEntity.getClass().equals(extensionService.getExtensionClass())) { Indexer<?> indexer = extensionService.getIndexer(); if (indexer != null) { indexer.indexEntity(fields, currentEntity); } } } if (currentEntity instanceof ExtensibleEntityBase) { queue.addAll(((ExtensibleEntityBase) currentEntity).getAllExtensions()); } } return fields; }
From source file:com.github.braully.graph.hn.GraphWS.java
public boolean checkIfHullSet(UndirectedSparseGraphTO<Integer, Integer> graph, int[] currentSet) { if (currentSet == null || currentSet.length == 0) { return false; }/*from w w w.j a v a 2 s. c o m*/ Set<Integer> fecho = new HashSet<>(); Collection vertices = graph.getVertices(); int[] aux = new int[graph.getVertexCount()]; for (int i = 0; i < aux.length; i++) { aux[i] = 0; } Queue<Integer> mustBeIncluded = new ArrayDeque<>(); for (Integer v : currentSet) { mustBeIncluded.add(v); } while (!mustBeIncluded.isEmpty()) { Integer verti = mustBeIncluded.remove(); fecho.add(verti); aux[verti] = INCLUDED; Collection<Integer> neighbors = graph.getNeighbors(verti); for (int vertn : neighbors) { if (vertn != verti) { int previousValue = aux[vertn]; aux[vertn] = aux[vertn] + NEIGHBOOR_COUNT_INCLUDED; if (previousValue < INCLUDED && aux[vertn] >= INCLUDED) { // includeVertex(graph, fecho, aux, verti); mustBeIncluded.add(vertn); } } } } // for (int i : currentSet) { // includeVertex(graph, fecho, aux, i); // } return fecho.size() == graph.getVertexCount(); }
From source file:it.geosolutions.geobatch.nrl.csvingest.CSVIngestAction.java
/** * // w ww .ja v a 2 s . c om */ public Queue<EventObject> execute(Queue<EventObject> events) throws ActionException { listenerForwarder.setTask("Check config"); // @autowired fields are injected *after* the checkConfiguration() is called checkInit(); listenerForwarder.started(); CSVIngestConfiguration configuration = getConfiguration(); if (configuration == null) { throw new IllegalStateException("ActionConfig is null."); } while (!events.isEmpty()) { EventObject event = events.poll(); if (event instanceof FileSystemEvent) { FileSystemEvent fse = (FileSystemEvent) event; File file = fse.getSource(); processCSVFile(file); // throw new ActionException(this, "Could not process " + event); } else { throw new ActionException(this, "EventObject not handled " + event); } } return new LinkedList<EventObject>(); }
From source file:com.connection.factory.SftpConnectionApacheLib.java
@Override public void readAllFilesWalkingPathWithListener(FileListener listener, String remotePath) { // List<RemoteFileObject> willReturnObject = new ArrayList<>(); Queue<RemoteFileObject> directorylist = new LinkedBlockingQueue<>(); RemoteFileObject object = null;//from w w w . ja v a2s. co m object = new FtpApacheFileObject(FileInfoEnum.DIRECTORY); object.setDirectPath(remotePath); directorylist.add(object); try { while (!directorylist.isEmpty()) { object = directorylist.poll(); List<ChannelSftp.LsEntry> list = command.ls(object.getPath()); for (ChannelSftp.LsEntry each : list) { if (each.getFilename().equals(".") || each.getFilename().equals("..")) { continue; } RemoteFileObject objectTemp = null; SftpATTRS attributes = each.getAttrs(); if (attributes.isDir()) { objectTemp = new SftpApacheFileObject(FileInfoEnum.DIRECTORY); objectTemp.setFileName(each.getFilename()); objectTemp.setAbsolutePath(object.getPath()); directorylist.add(objectTemp); } else if (attributes.isReg()) { objectTemp = new SftpApacheFileObject(FileInfoEnum.FILE); objectTemp.setFileName(each.getFilename()); objectTemp.setAbsolutePath(object.getPath()); objectTemp.setFileSize(attributes.getSize()); objectTemp.setDate(attributes.getMtimeString()); objectTemp.setFileType(); listener.handleRemoteFile(object); } } object = null; list = null; } } catch (ConnectionException | SftpException ex) { // ex.printStackTrace(); } //return willReturnObject; }