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

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


            if (node instanceof ContentCollection) {
                logger.warning("Found content collection " + node.getPath() +
                        " in x-apps collection, ignorning.");
                continue;
            }
            ContentResource resource = (ContentResource)node;
            try {
                XAppRegistryItem item = parseResource(resource);
                itemList.add(item);
            } catch (ContentRepositoryException excp) {
                logger.log(Level.WARNING, "Unable to read entry in x-apps: " +
View Full Code Here


        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();
        Writer w = new OutputStreamWriter(os);
        item.encode(w);
        byte b[] = os.toByteArray();
        resource.put(b);
    }
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

        int returnVal = chooser.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            String fileName = tableSelectedNode.getName();
            File out = new File(chooser.getSelectedFile(), fileName);
            try {
                ContentResource r = (ContentResource) tableSelectedNode;
                r.get(out);
            } catch (java.lang.Exception cre) {
                logger.log(Level.WARNING,
                        "Unable to download " + fileName, cre);

                // Display a dialog indicating that the delete failed.
View Full Code Here

        File file = chooser.getSelectedFile();
        String name = file.getName();
        if (file.exists() == true) {
            try {
                ContentCollection c = (ContentCollection) treeSelectedNode;
                ContentResource r = (ContentResource) c.createChild(
                        name, ContentNode.Type.RESOURCE);
                r.put(file);
                jtable.setContentCollection(c);
            } catch (java.lang.Exception excp) {
                logger.log(Level.WARNING, "Unable to upload " + file, excp);

                // Display a dialog indicating that the delete failed.
View Full Code Here

            modifiedLabel.setText("");
            urlLabel.setText("");

            enableDelete = true;
        } else if (selected instanceof ContentResource) {
            ContentResource r = (ContentResource) selected;

            typeLabel.setText("File");
            sizeLabel.setText(String.valueOf(r.getSize()));
           
            DateFormat df = DateFormat.getDateInstance();
            modifiedLabel.setText(df.format(r.getLastModified()));

            try {
                urlLabel.setText(r.getURL().toExternalForm());
            } catch (ContentRepositoryException cre) {
                logger.log(Level.WARNING, "Unable to get URL for " + r, cre);
                urlLabel.setText("Error: " + cre.getMessage());
            }
View Full Code Here

    private void uploadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uploadButtonActionPerformed
        File file = new File(fileTF.getText());
        if (file.exists()) {
            try {
                ContentResource r = (ContentResource)
                        directory.createChild(file.getName(), ContentNode.Type.RESOURCE);
                r.put(file);

                setCollection(directory);
            } catch (ContentRepositoryException cre) {
                logger.log(Level.WARNING, "Unable to upload " + file, cre);
            } catch (IOException ioe) {
View Full Code Here

            }
        }
    }//GEN-LAST:event_uploadButtonActionPerformed

    private void downloadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_downloadButtonActionPerformed
        ContentResource selected = (ContentResource) getSelection();

        JFileChooser chooser = new JFileChooser("Choose a directory");
        chooser.setFileFilter(new FileFilter() {
            @Override
            public boolean accept(File f) {
                return f.isDirectory();
            }

            @Override
            public String getDescription() {
                return "Directories";
            }
        });
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        chooser.setDialogType(JFileChooser.SAVE_DIALOG);
       
        int returnVal = chooser.showOpenDialog(this);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File out = new File(chooser.getSelectedFile(), selected.getName());
            try {
                selected.get(out);
            } catch (ContentRepositoryException cre) {
                logger.log(Level.WARNING, "Unable to download " + out, cre);
            } catch (IOException ioe) {
                logger.log(Level.WARNING, "Unable to write " + out, ioe);
            }
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

            ContentCollection csColl = (ContentCollection) grpusrs.getChild("GoToCoverScreen");
            if(csColl==null) {
                csColl = (ContentCollection) grpusrs.createChild("GoToCoverScreen", ContentNode.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 GoToCoverScreen.xml in " + collection.getPath());
               return null;
           } else {
               LOGGER.warning("find GoToCoverScreen.xml in " + collection.getPath());
           }
          
          
           Reader r = new InputStreamReader(resource.getURL().openStream());
           GoToCoverScreenInfo out = GoToCoverScreenInfo.decode(r);
           return out;
        } catch (ContentRepositoryException ex) {
            Logger.getLogger(WonderlandUserListPresenter.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.