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

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


            }
            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


        String path = origCursorFilePath;
        ContentRepositoryRegistry registry = ContentRepositoryRegistry.getInstance();
        ContentRepository repo = registry.getRepository(LoginManager.getPrimary());
        try {
            ContentCollection c = repo.getUserRoot();
            ContentResource r = (ContentResource) c.getChild(cursorFile.getName());

            if(r!=null) {

                //file is already exist
                Object[] options = {
                    BUNDLE.getString("Replace"),
                    BUNDLE.getString("Use_Existing"),
                    BUNDLE.getString("Cancel")
                };
                String msg = MessageFormat.format(
                        BUNDLE.getString("Replace_Question"), file.getName());
                String title = BUNDLE.getString("Replace_Title");

                int result = JOptionPane.showOptionDialog(this, msg, title,
                        JOptionPane.YES_NO_CANCEL_OPTION,
                        JOptionPane.QUESTION_MESSAGE, null, options, options[0]);

                // If the user hits Cancel or a "closed" action (e.g. Escape key)
                // then just return
                if ((result == JOptionPane.CANCEL_OPTION)
                        || (result == JOptionPane.CLOSED_OPTION)) {
                    path = origCursorFilePath;
                }

                // If the content exists and we do not want to upload a new version,
                // then simply create it and return.
                if (result == JOptionPane.NO_OPTION) {
                    path = "wlcontent:/"+r.getPath();
                }
                if(result == JOptionPane.YES_OPTION) {
                    try {
                        r.put(temp);
                        path = "wlcontent:/"+r.getPath();
                    } catch (IOException ex) {
                        Logger.getLogger(BasicJPanel.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            } else {
               
                //create a new file
                r = (ContentResource) c.createChild(cursorFile.getName()
                            , ContentNode.Type.RESOURCE);
                try {
                    r.put(temp);
                    path = "wlcontent:/"+r.getPath();
                } catch (IOException ex) {
                    Logger.getLogger(BasicJPanel.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        } catch (Exception ex) {
View Full Code Here

            ContentCollection c = repo.getUserRoot();
            try {
                /*
                 * Remove file if it exists.
                 */
                ContentResource r = (ContentResource) c.removeChild(image.getName());
            } catch (Exception e) {
            }
           
            ContentResource r = (ContentResource) c.createChild(
                image.getName(), ContentNode.Type.RESOURCE);
            try {
                r.put(image);
                uri = "wlcontent:/"+r.getPath();
            } catch (IOException ex) {
                Logger.getLogger(PortalComponentProperties.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (ContentRepositoryException ex) {
            Logger.getLogger(PortalComponentProperties.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

        if (node != null) {
            logger.info("recording already exists, so removing: " + recordingName);
            dirNode.removeChild(recordingName);
        }
        node = dirNode.createChild(recordingName, Type.RESOURCE);
        ContentResource resource = (ContentResource) node;
        logger.info("created a node for the audio file: " + resource);
        resource.put(audioFile);
    }
View Full Code Here

            ContentCollection c = repo.getUserRoot();
            try {
                /*
                 * Remove file if it exists.
                 */
                ContentResource r = (ContentResource) c.removeChild(image.getName());
            } catch (Exception e) {
            }
           
            ContentResource r = (ContentResource) c.createChild(
                image.getName(), ContentNode.Type.RESOURCE);
            try {
               
                r.put(image);
               
                uri = "wlcontent:/"+r.getPath();
            } catch (IOException ex) {
                Logger.getLogger(PlacemarkComponentProperties.class.getName()).log(Level.SEVERE, null, ex);
            }
        } catch (ContentRepositoryException ex) {
            Logger.getLogger(PlacemarkComponentProperties.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

                String[] urls = imageURL.toString().split("/");
                String fname = urls[urls.length-1];
                String userName = urls[3];
                ContentCollection user = cr.getUserRoot(userName);
               
                ContentResource res = (ContentResource) user.getChild(fname);
               
                BufferedImage bimg = ImageIO.read(res.getInputStream());
                if(bimg.getWidth()>width || bimg.getHeight()>height) {
                    if(bimg.getWidth()>width && bimg.getHeight()>height) {
                        if(bimg.getWidth()-width>bimg.getHeight()-height) {
                            float nw = width;
                            float nh = (width*bimg.getHeight())/bimg.getWidth();
 
View Full Code Here

     */
    private static PlacemarkList getItemList(ContentCollection collection)
            throws ContentRepositoryException, JAXBException {

        // Find the placemarks.xml file and parse as a PlacemarkList object.
        ContentResource resource = (ContentResource)collection.getChild("placemarks.xml");
        if (resource == null) {
            logger.warning("Unable to find placemarks.xml in " + collection.getPath());
            return new PlacemarkList();
        } else {
            logger.warning("find placemarks.xml in " + collection.getPath());
        }
       
        Reader r = new InputStreamReader(resource.getInputStream());
        PlacemarkList out = PlacemarkList.decode(r);
   
        // Filtering out placemarks that are not for the server we're logged on.
        // getPlacemarksAsList() returns a copy, so we can safely remove
        // placemarks without ConcurrentModificationExceptions
View Full Code Here

     */
    private static void setItemList(ContentCollection collection, PlacemarkList placemarkList)
            throws ContentRepositoryException, JAXBException {

        // Find the placemarks.xml file, creating it if necessary.
        ContentResource resource = (ContentResource)collection.getChild("placemarks.xml");
        if (resource == null) {
            resource = (ContentResource)collection.createChild("placemarks.xml", Type.RESOURCE);
        }

        // Write the new list to the resource
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        Writer w = new OutputStreamWriter(os);
        placemarkList.encode(w);
        resource.put(os.toByteArray());
    }
View Full Code Here

           
            ArrayList<ContentNode> resources = (ArrayList<ContentNode>)csColl.getChildren();
            if (resources != null && resources.size()!=0) {
                csColl.removeChild(resources.get(0).getName());
            }
            ContentResource resource = (ContentResource)csColl.createChild("LoginCoverScreen"+new Date().getTime()+".xml", Type.RESOURCE);

            // Write the new list to the resource
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            Writer w = new OutputStreamWriter(os);
            loginCoverScreenInfo.encode(w);
            resource.put(os.toByteArray());
        } catch (ContentRepositoryException ex) {
            Logger.getLogger(PlacemarkUtils.class.getName()).log(Level.SEVERE, null, ex);
        } catch (JAXBException ex) {
            Logger.getLogger(PlacemarkUtils.class.getName()).log(Level.SEVERE, null, ex);
        }
View Full Code Here

            ContentCollection csColl = (ContentCollection) grpusrs.getChild("LoginCoverScreen");
            if(csColl==null) {
                csColl = (ContentCollection) grpusrs.createChild("LoginCoverScreen", Type.COLLECTION);
            }
           ArrayList<ContentNode> resources = (ArrayList<ContentNode>) csColl.getChildren();
           ContentResource resource = null;
           if(resources!=null && !resources.isEmpty()) {
                resource = (ContentResource)csColl.getChildren().get(0);
           }
           if (resource == null) {
               logger.warning("Unable to find LoginCoverScreen.xml in " + grpusrs.getPath());
               return null;
           } else {
               logger.warning("find LoginCoverScreen.xml in " + grpusrs.getPath());
           }
          
           Reader r = new InputStreamReader(resource.getURL().openStream());
           LoginCoverScreenInfo out = LoginCoverScreenInfo.decode(r);
           return out;
        } catch (ContentRepositoryException ex) {
            Logger.getLogger(PlacemarkUtils.class.getName()).log(Level.SEVERE, null, ex);
        } catch (JAXBException ex) {
View Full Code Here

TOP

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

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.