Examples of WFSCell


Examples of org.jdesktop.wonderland.tools.wfs.WFSCell

        for (int i = 0; i < paths.length; i++) {

            // First fetch the cell. If it does not exist, then return a bad
            // response. This is an error since the path should never contain
            // a Cell that does not exist.
            WFSCell cell = dir.getCellByName(paths[i]);
            if (cell == null) {
                LOGGER.warning("Unable to find WFS Cell with path: " + path);
                return Response.status(Response.Status.BAD_REQUEST).build();
            }
           
            // Next, get the directory associated with the cell. All elements
            // the path should have a Cell directory, except perhaps for the
            // last element.
            dir = cell.getCellDirectory();
            if (dir == null && i < paths.length - 1) {
                // Some interior path does not have a Cell directory. This is
                // an error.
                LOGGER.warning("Unable to find WFS Cell directory with path: " +
                        path);
                return Response.status(Response.Status.BAD_REQUEST).build();
            }
            else if (dir == null) {
                // Otherwise, if the final path does not have a Cell directory,
                // this is ok. It just means that Cell has no children, so we
                // return an empty list.
                LOGGER.fine("Did not find a WFS Cell directory for path " +
                        path + ". This is ok, returning empty list.");
                CellList children = new CellList(path, new Cell[] {});
                return Response.ok(children).build();
            }
        }
       
        // If we have reached here, we have 'dir' with the directory in which
        // the cells should be. Create a WFSCellChildren object which is used
        // to serialize the result.
        String names[] = dir.getCellNames();
        if (names == null) {
            // If the directory exists, yet there are no children, this is ok.
            // Just return an empty list.
            LOGGER.fine("Did not find WFS Cell children for path " + path +
                    ". This is ok, returning empty list.");
            CellList children = new CellList(path, new Cell[]{});
            return Response.ok(children).build();
        }

        LOGGER.fine("For WFS Cell " + path + " # Children " + names.length);
       
        // Loop through and create the WFSCellChildren object, we need to
        // include the last modified time so that the client can check whether
        // the cell has been modified or not.
        LinkedList<Cell> list = new LinkedList<Cell>();
        for (String name : names) {
            WFSCell cell = dir.getCellByName(name);
            if (cell == null) {
                LOGGER.warning("No WFS cell exists with name " + name);
                continue;
            }
            LOGGER.fine("Found WFS child " + name + " in path " + path);
            list.add(new Cell(name, cell.getLastModified()));
        }
       
        // Convert the list of CellChilds to an array, form into a CellList and
        // send the CellList directly to the client.
        Cell[] childs = list.toArray(new Cell[] {});
View Full Code Here

Examples of org.jdesktop.wonderland.tools.wfs.WFSCell

        for (int i = 0; i < paths.length - 1; i++) {
            /*
             * First fetch the cell. If it does not exist, then return a bad
             * response.
             */
            WFSCell cell = dir.getCellByName(paths[i]);
            if (cell == null) {
                logger.warning("WFSManager: Unable to find cell with path: " + path);
                ResponseBuilder rb = Response.status(Response.Status.BAD_REQUEST);
                return rb.build();
            }
           
            /*
             * Next, get the directory associated with the cell. It also needs
             * to exist, otherwise, return a bad response.
             */
            if ((dir = cell.getCellDirectory()) == null) {
                logger.warning("WFSManager: Unable to find directory with path: " + path);
                ResponseBuilder rb = Response.status(Response.Status.BAD_REQUEST);
                return rb.build();
            }
        }
       
        /*
         * If we have reached here, we have one remaining element in the path
         * and 'dir' holds the directory in which the cell should be.
         */
        WFSCell cell = dir.getCellByName(paths[paths.length - 1]);
        if (cell == null) {
            logger.warning("WFSManager: Unable to find final cell with path: " + path);
            ResponseBuilder rb = Response.status(Response.Status.BAD_REQUEST);
            return rb.build();
        }
       
        /*
         * Load in the cell and stream its setup information to the client.
         */
        try {
            /* Fetch the essential configuration information, check for null */
            String setup = cell.getCellSetup();
            if (setup == null) {
                logger.warning("WFSManager: Unable to find cell setup: " + path);
                ResponseBuilder rb = Response.status(Response.Status.BAD_REQUEST);
                return rb.build();
            }
View Full Code Here

Examples of org.jdesktop.wonderland.tools.wfs.WFSCell

        /*
         * Fetch an array of the names of the child cells. Check this is not
         * null, although this getChildren() should return an empty array
         * instead.
         */
        WFSCell cells[] = dir.getCells();
        for (WFSCell cell : cells) {
            cellList.addLast(new Cell(cell.getCanonicalName(), cell.getLastModified()));
            if (cell.getCellDirectory() != null) {
                children.addLast(cell.getCellDirectory());
            }
View Full Code Here

Examples of org.jdesktop.wonderland.tools.wfs.WFSCell

        if (cellDescriptor.getParentPath() != null) {
            String parentCells[] = cellDescriptor.getParentPath().getParentPaths();
            for (int i = 0; i < parentCells.length; i++) {
                // First fetch the cell. If it does not exist, then return a bad
                // response.
                WFSCell parentCell = wfsDirectory.getCellByName(parentCells[i]);
                if (parentCell == null) {
                    logger.warning("[WFS] Unable to find cell " + parentCells[i] +
                            " in WFS " + rootPath);
                    return Response.status(Response.Status.BAD_REQUEST).build();
                }

                // Next, get the directory associated with the cell. It also needs
                // to exist, otherwise, return a bad response. The only exception
                // is the last parent in the cell, which may not have its child
                // directory yet created.
                wfsDirectory = parentCell.getCellDirectory();
                if (i < parentCells.length - 1 && wfsDirectory == null) {
                    // This means that a parent cell directory, other than the
                    // immediate parent does not exist (which means the immediate
                    // parent cell does not exist, which is very bad!
                    logger.warning("[WFS] Unable to find directory for cell " +
                            parentCells[i] + " in WFS " + rootPath);
                    return Response.status(Response.Status.BAD_REQUEST).build();
                }
                else if (wfsDirectory == null) {
                    // Unless we are talking about the cell directory associated
                    // with the parent. In which case we should create it.
                    try {
                        wfs.acquireOwnership();
                        wfsDirectory = parentCell.createCellDirectory();
                        parentCell.write();
                    } catch (java.lang.InterruptedException excp) {
                        logger.log(Level.WARNING, "[WFS] Unable to lock WFS " +
                                rootPath, excp);
                        return Response.status(Response.Status.BAD_REQUEST).build();
                    } catch (java.lang.Exception excp) {
                        logger.log(Level.WARNING, "[WFS] Failed to create WFS " +
                                " directory " + rootPath);
                        return Response.status(Response.Status.BAD_REQUEST).build();
                    } finally {
                        wfs.release();
                    }
                }
            }
        }
       
        // When we have reached here, the directory in which to place the new
        // cell is in 'wfsDirectory'. We create the cell and write the WFS
        // back out to its disk. In this case, the cell name is the name of
        // the file, which should be <Cell Name>-<Cell ID>.
        try {
            wfs.acquireOwnership();
            String cellName = cellDescriptor.getCellUniqueName();
            WFSCell cell = wfsDirectory.addCell(cellName);
            if (cell == null) {
                logger.warning("[WFS] Failed to create cell " + cellName +
                        " in WFS " + rootPath);
                return Response.status(Response.Status.BAD_REQUEST).build();
            }
            cell.setCellSetup(cellDescriptor.getSetupInfo());
            wfsDirectory.write();
        } catch (java.lang.Exception excp) {
            logger.log(Level.WARNING, "[WFS] Unable to lock WFS " + rootPath, excp);
            return Response.status(Response.Status.BAD_REQUEST).build();
        } finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.