Package org.olat.core.util.vfs

Examples of org.olat.core.util.vfs.VFSLeaf


   * @return The Feed upon success
   */
  public static Feed readFeedFile(VFSContainer feedContainer) {
    Feed myFeed = null;
    if (feedContainer != null) {
      VFSLeaf leaf = (VFSLeaf) feedContainer.resolve(FEED_FILE_NAME);
      if (leaf != null) {
        myFeed = (Feed) XStreamHelper.readObject(xstream, leaf.getInputStream());
      }
    } else {
      log.error("Feed xml-file could not be found on file system. Feed container: " + feedContainer);
    }
    return myFeed;
View Full Code Here


   *
   * @param container
   * @return The item
   */
  public static Item loadItem(VFSItem container) {
    VFSLeaf itemLeaf = null;
    Item item = null;

    if (container != null) {
      itemLeaf = (VFSLeaf) container.resolve(ITEM_FILE_NAME);
      if (itemLeaf != null) {
        item = (Item) XStreamHelper.readObject(xstream, itemLeaf.getInputStream());
      }
    }
    return item;
  }
View Full Code Here

          // Set the file properties to the item and store the file
          setEnclosure(file, item, reloadedFeed);

          // Write the item.xml file
          VFSContainer itemContainer = createItemContainer(feed, item);
          VFSLeaf itemFile = itemContainer.createChildLeaf(ITEM_FILE_NAME);
          XStreamHelper.writeObject(xstream, itemFile, item);

          // finally add the item to the feed
          reloadedFeed.add(item);
          reloadedFeed.setLastModified(item.getLastModified());
View Full Code Here

      }
    }
    // Write the feed file. (Items are saved when adding them.)
    feed.sortItems();
    VFSContainer container = getFeedContainer(feed);
    VFSLeaf leaf = (VFSLeaf) container.resolve(FEED_FILE_NAME);
    XStreamHelper.writeObject(xstream, leaf, feed);
    initFeedCache().update(feed.getResourceableId().toString(), feed);
    enrichRepositoryEntryByFeedInformation(feed);
  }
View Full Code Here

      String saveFileName = getSaveFileName(file.getUploadFileName());

      File renamed = new File(uploadedFile.getParent() + "/" + saveFileName);
      uploadedFile.renameTo(renamed);
      VFSLeaf mediaFile = new LocalFileImpl(renamed);
      itemMediaContainer.copyFrom(mediaFile);

      // Update the enclosure
      Enclosure enclosure = new Enclosure();
      enclosure.setFileName(saveFileName);
View Full Code Here

  public File getItemEnclosureFile(Item item, Feed feed) {
    VFSContainer mediaDir = getItemMediaContainer(item, feed);
    Enclosure enclosure = item.getEnclosure();
    File file = null;
    if (mediaDir != null && enclosure != null) {
      VFSLeaf mediaFile = (VFSLeaf) mediaDir.resolve(enclosure.getFileName());
      if (mediaFile != null && mediaFile instanceof LocalFileImpl) {
        file = ((LocalFileImpl) mediaFile).getBasefile();
      }
    }
    return file;
View Full Code Here

            if (file != null) {
              setEnclosure(file, item, reloadedFeed);
            }
           
            // Write the item.xml file
            VFSLeaf itemFile = (VFSLeaf) getItemContainer(item, reloadedFeed).resolve(ITEM_FILE_NAME);
            XStreamHelper.writeObject(xstream, itemFile, item);
           
            update(reloadedFeed, false);           
          } else {
            // do nothing, item was deleted by someone in the meantime
View Full Code Here

  /**
   * @see org.olat.modules.webFeed.managers.FeedManager#getFeedArchiveMediaResource(org.olat.core.id.OLATResourceable)
   */
  @Override
  public VFSMediaResource getFeedArchiveMediaResource(OLATResourceable resource) {
    VFSLeaf zip = getFeedArchive(resource);
    return new VFSMediaResource(zip);
  }
View Full Code Here

                //set author fallback
                item.setAuthor(author);
                //update item.xml
                VFSContainer itemContainer = getItemContainer(item, feed);
                if(itemContainer != null) {
                  VFSLeaf itemFile = (VFSLeaf)itemContainer.resolve(ITEM_FILE_NAME);
                  XStreamHelper.writeObject(xstream, itemFile, item);
                }
              }
            }
          }
          return Boolean.TRUE;
        }
      });
    }
   
    // synchronize all zip processes for this feed
    // o_clusterOK by:fg
    VFSLeaf zip = CoordinatorManager.getCoordinator().getSyncer().doInSync(resource, new SyncerCallback<VFSLeaf>() {
      public VFSLeaf execute() {
        // Delete the old archive and recreate it from scratch
        String zipFileName = getZipFileName(resource);
        VFSItem oldArchive = rootContainer.resolve(zipFileName);
        if (oldArchive != null) {
View Full Code Here

      // Save the new image
      File uploadedFile = image.getUploadFile();
      String saveFileName = getSaveFileName(image.getUploadFileName());
      File renamed = new File(uploadedFile.getParent() + "/" + saveFileName);
      uploadedFile.renameTo(renamed);
      VFSLeaf imageLeaf = new LocalFileImpl(renamed);
      getFeedMediaContainer(feed).copyFrom(imageLeaf);
      feed.setImageName(saveFileName);
    }
  }
View Full Code Here

TOP

Related Classes of org.olat.core.util.vfs.VFSLeaf

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.