Package org.jdesktop.wonderland.modules.contentrepo.common

Examples of org.jdesktop.wonderland.modules.contentrepo.common.ContentNode


        // The model loader may use a different filename, so check the directory exists rather
        // than the existance of the .dep file.
        String fileName = "art/" + file.getName();
        ContentCollection userRoot = getUserRoot();
        try {
            ContentNode node = userRoot.getChild(fileName);
            if (node != null && node instanceof ContentCollection) {
                // Search for the dep file, and return it's url
                List<ContentNode> children = ((ContentCollection)node).getChildren();
                for(ContentNode c : children) {
                    if (c instanceof ContentResource && ((ContentResource)c).getName().endsWith(".dep")) {
View Full Code Here


        String fName = f.getName();
        if (f.isDirectory() == true) {
            // We need to create the child directory if it does not yet exist.
            // If it does exist, but is not a collection, then we need to delete
            // the existing resource and create the new collection
            ContentNode node = n.getChild(fName);
            if (node == null) {
                node = n.createChild(fName, Type.COLLECTION);
            }
            else if (!(node instanceof ContentCollection)) {
                node.getParent().removeChild(node.getName());
                node = n.createChild(fName, Type.COLLECTION);
            }
            ContentCollection dir = (ContentCollection)node;

            // Recursively descend the children and copy them over too.
            File[] subdirs = f.listFiles();
            if (subdirs != null) {
                for (File child : subdirs) {
                    copyFiles(child, dir);
                }
            }
        } else {
            // For a file, create the file if it does not yet exist. If it does
            // exist, but is not a resource, then delete the existing node and
            // create a new resource
            ContentNode node = n.getChild(fName);
            if (node == null) {
                node = n.createChild(fName, Type.RESOURCE);
            }
            else if (!(node instanceof ContentResource)) {
                node.getParent().removeChild(node.getName());
                node = n.createChild(fName, Type.RESOURCE);
            }
            ContentResource resource = (ContentResource)node;
            resource.put(f);
        }
View Full Code Here

        logger.info("recording root: " + recordingRoot);
        File audioFile = new File(recorder.getRecordPath());
        if (!audioFile.exists()) {
            throw new FileNotFoundException();
        }
        ContentNode node = recordingRoot.getChild(AUDIO_RECORDINGS_DIRECTORY);
        if (node == null) {
            node = recordingRoot.createChild(AUDIO_RECORDINGS_DIRECTORY, Type.COLLECTION);
        }
        ContentCollection dirNode = (ContentCollection) node;
        logger.info("directory for audio recordings: " + dirNode);
View Full Code Here

    @GET
    @Path("get/{id}")
    @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Response get(@PathParam("id") String id) {
        try {
            ContentNode node = dir.getChild(id);
            if (node == null || !(node instanceof ContentResource)) {
                throw new WebApplicationException(Response.Status.NOT_FOUND);
            }
           
            final ErrorReport log = read((ContentResource) node);
View Full Code Here

        if (attachment != null) {
            asAttachment = Boolean.parseBoolean("attachment");
        }
       
        try {
            ContentNode node = dir.getChild(id);
            if (node == null || !(node instanceof ContentResource)) {
                throw new WebApplicationException(Response.Status.NOT_FOUND);
            }
           
            final ErrorReport log = read((ContentResource) node);
View Full Code Here

    @GET
    @Path("delete/{id}")
    public Response download(@PathParam("id") String id)
    {
        try {
            ContentNode node = dir.getChild(id);
            if (node == null || !(node instanceof ContentResource)) {
                throw new WebApplicationException(Response.Status.NOT_FOUND);
            }
           
            dir.removeChild(id);
View Full Code Here

        // Fetch the content node for the "x-apps" directory under "system". If
        // "x-apps" isn't there, then create it.
        ContentCollection xAppsCollection = null;
        try {
            ContentCollection sysRoot = wcr.getSystemRoot();
            ContentNode xappsNode = sysRoot.getChild("x-apps");
            if (xappsNode == null) {
                xappsNode = sysRoot.createChild("x-apps", Type.COLLECTION);
            }
            xAppsCollection = (ContentCollection)xappsNode;
        } catch (ContentRepositoryException excp) {
View Full Code Here

        // We need to check whether the selected app name has already been taken.
        // If so, log an error and return. Create a file, based upon the app
        // name for the new X11 app, creating it if necessary
        String nodeName = appName + ".xml";
        ContentNode appNode = xAppsCollection.getChild(nodeName);
        if (appNode != null) {
            String msg = "The app name " + appName + " already exists. Cancelling.";
            error(request, response, msg);
            return;
        }
View Full Code Here

        // First try to find the resource, if it exists, then simply upload the
        // new bits. Otherwise create the resource and upload the new bits
        try {
            userRoot = repo.getUserRoot();
            ContentNode node = (ContentNode)userRoot.getChild(fileName);
            if (node == null) {
                node = (ContentNode)userRoot.createChild(fileName, Type.RESOURCE);
            }
            ((ContentResource)node).put(file);
        } catch (ContentRepositoryException excp) {
View Full Code Here

        // First fetch the content collection of the user-specific X Apps items
        // and look for the file <app name>.xml.
        ContentCollection userNode = getUserXAppContentCollection();
        String nodeName = item.getAppName() + ".xml";
        ContentNode appNode = userNode.getChild(nodeName);
        if (appNode == null) {
            appNode = userNode.createChild(nodeName, Type.RESOURCE);
        }
        ContentResource resource = (ContentResource)appNode;
        ByteArrayOutputStream os = new ByteArrayOutputStream();
View Full Code Here

TOP

Related Classes of org.jdesktop.wonderland.modules.contentrepo.common.ContentNode

Copyright © 2018 www.massapicom. 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.