Package ch.entwine.weblounge.common.content.file

Examples of ch.entwine.weblounge.common.content.file.FileResource


   * @throws IllegalStateException
   */
  @Test
  public void testWithoutModification() throws ContentRepositoryException,
  IllegalStateException, IOException {
    FileResource fileResource = new FileResourceImpl(documentURI);

    SearchQuery q = new SearchQueryImpl(site);
    SearchResult result = repository.find(q);
    assertEquals(1, result.getDocumentCount());

View Full Code Here


    } catch (ContentRepositoryException e) {
      logger.error("Error trying to look up file {} from {}", fileId, repository);
      return SKIP_BODY;
    }

    FileResource file = null;
    FileContent fileContent = null;

    // Determine the languages
    Language language = request.getLanguage();

    // Store the result in the jsp page context
    try {
      file = (FileResource) repository.get(uri);
      file.switchTo(language);

      Language contentLanguage = null;
      contentLanguage = LanguageUtils.getPreferredContentLanguage(file, request, site);
      if (contentLanguage == null) {
        logger.warn("File {} does not have suitable content", file);
        return SKIP_BODY;
      }

      fileContent = file.getContent(contentLanguage);
    } catch (ContentRepositoryException e) {
      logger.warn("Error trying to load file " + uri + ": " + e.getMessage(), e);
      return SKIP_BODY;
    }

    // TODO: Check the permissions

    // Store the file and the file content in the request
    stashAndSetAttribute(FileResourceTagExtraInfo.FILE, file);
    stashAndSetAttribute(FileResourceTagExtraInfo.FILE_CONTENT, fileContent);

    // Add cache tags to response
    response.addTag(CacheTag.Resource, file.getURI().getIdentifier());
    response.addTag(CacheTag.Url, file.getURI().getPath());

    return EVAL_BODY_INCLUDE;
  }
View Full Code Here

   * {@link ch.entwine.weblounge.common.impl.content.file.FileResourceImpl#compareTo(ch.entwine.weblounge.common.language.Localizable, ch.entwine.weblounge.common.language.Language)}
   * .
   */
  @Test
  public void testCompareTo() {
    FileResource p2 = new FileResourceImpl(new FileResourceURIImpl(site, "/test/2", Resource.LIVE));
    p2.setTitle(germanTitle, german);
    assertEquals(0, file.compareTo(p2, german));
  }
View Full Code Here

    for (ResourceMetadata<?> metadataItem : metadata) {
      if (XML.equals(metadataItem.getName())) {
        String resourceXml = (String) metadataItem.getValues().get(0);
        try {
          ResourceReader<FileContent, FileResource> reader = getReader();
          FileResource file = reader.read(IOUtils.toInputStream(resourceXml, "UTF-8"), site);
          return file;
        } catch (SAXException e) {
          logger.warn("Error parsing file from metadata", e);
          return null;
        } catch (IOException e) {
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.content.file.FileResource

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.