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

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


            while (iter.hasNext() == true) {
                FileItemStream item = iter.next();
                String name = item.getName();
                InputStream stream = item.openStream();
                if (item.isFormField() == false) {
                    ContentResource child = (ContentResource)
                            dir.createChild(name, ContentNode.Type.RESOURCE);

                    File tmp = File.createTempFile("contentupload", "tmp");
                    RunUtil.writeToFile(stream, tmp);
                    child.put(tmp);
                    tmp.delete();
                }
            }

            return node;
View Full Code Here


               
        try {
            WebContentRepository repo =
                    WebContentRepositoryRegistry.getInstance().getRepository(context);
            ContentCollection root = repo.getRoot();
            ContentResource obj = (ContentResource) root.getChild(url.getHost() + "/" + url.getPath());
           
            return new WlContentURLConnection(url, obj);
           
        } catch (ContentRepositoryException ce) {
            throw new IOException(ce);
View Full Code Here

    /**
     * Reads the placemarks.xml file and returns a PlacemarkList object
     */
    private PlacemarkList getPlacemarkList() throws ContentRepositoryException, JAXBException {
        ContentResource resource = getPlacemarksResource();
        Reader r = new InputStreamReader(resource.getInputStream());
        return PlacemarkList.decode(r);
    }
View Full Code Here

    /**
     * Writes the PlacemarkList object to the placemarks.xml file.
     */
    private void setPlacemarkList(PlacemarkList placemarkList) throws ContentRepositoryException, JAXBException {
        ContentResource resource = getPlacemarksResource();
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        Writer w = new OutputStreamWriter(os);
        placemarkList.encode(w);
        resource.put(os.toByteArray());
    }
View Full Code Here

            c = (ContentCollection)sysRoot.createChild("placemarks", Type.COLLECTION);
        }

        // Try to find the "placemarks.xml" file. If it does not exist, then
        // create it with an empty PlacemarksList.
        ContentResource r = (ContentResource)c.getChild("placemarks.xml");
        if (r == null) {
            r = (ContentResource)c.createChild("placemarks.xml", Type.RESOURCE);
            PlacemarkList placemarkList = new PlacemarkList();
            ByteArrayOutputStream os = new ByteArrayOutputStream();
            Writer w = new OutputStreamWriter(os);
            placemarkList.encode(w);
            r.put(os.toByteArray());
        }
        return r;
    }
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

    public static ErrorReport read(String id)
            throws ContentRepositoryException, JAXBException
    {
        ContentCollection dir = getContentDir();
        ContentResource resource = (ContentResource) dir.getChild(id);
        if (resource == null) {
            throw new ContentRepositoryException("No such file: " + id);
        }
       
        Unmarshaller u = getContext().createUnmarshaller();
        return (ErrorReport) u.unmarshal(resource.getInputStream());
    }
View Full Code Here

            throws ContentRepositoryException, JAXBException
    {
        ServerSessionManager ssm = LoginManager.getPrimary();   
        ContentCollection dir = getContentDir();
       
        ContentResource file;
        if (report.getId() == null) {
            // create a new file
            String fileName;       
            int index = 0;
            DateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
            do {
                fileName = ssm.getUsername() + "-" + df.format(new Date());
                fileName += (index == 0)?"":index;
           
                index++;
            } while (dir.getChild(fileName) != null);
       
            file = (ContentResource)
                dir.createChild(fileName, ContentNode.Type.RESOURCE);
        } else {
            // update an existing file
            file = (ContentResource) dir.getChild(report.getId());
        }
       
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        Marshaller m = getContext().createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
        m.marshal(report, baos);
   
        file.put(baos.toByteArray());
    }
View Full Code Here

        try {
      /*
       * Remove file if it exists.
       */
            ContentResource r = (ContentResource) audioCollection.removeChild(file.getName());
  } catch (Exception e) {
  }

        try {
            ContentResource r = (ContentResource) audioCollection.createChild(
                file.getName(), ContentNode.Type.RESOURCE);

            r.put(file);
        } catch (Exception e) {
            String message = BUNDLE.getString("Upload_Failed_Exception");
            message = MessageFormat.format(message, file, e.getMessage());
            error(message);
        }
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.