Package ch.entwine.weblounge.common.content

Examples of ch.entwine.weblounge.common.content.ResourceContent


    System.setProperty("java.awt.headless", "true");
    System.setProperty("weblounge.jai", Boolean.TRUE.toString());
  }

  public void setUp() {
    ResourceContent resourceContent = EasyMock.createNiceMock(ResourceContent.class);
    EasyMock.expect(resourceContent.getMimetype()).andReturn("image/png");
    EasyMock.replay(resourceContent);
    resource = EasyMock.createNiceMock(Resource.class);
    EasyMock.expect(resource.getContent((Language) EasyMock.anyObject())).andStubReturn(resourceContent);
    EasyMock.replay(resource);
  }
View Full Code Here


    String eTag = ResourceUtils.getETagValue(scaledResourceFile);
    response.tag(eTag);

    // Add filename header
    String filename = null;
    ResourceContent resourceContent = resource.getContent(language);
    if (resourceContent != null)
      filename = resourceContent.getFilename();
    if (StringUtils.isBlank(filename))
      filename = scaledResourceFile.getName();
    response.header("Content-Disposition", "inline; filename=" + filename);

    // Content length
View Full Code Here

      if (!SecurityUtils.userHasRole(user, SystemRole.EDITOR))
        throw new WebApplicationException(Status.UNAUTHORIZED);

      // Try to create the resource content
      InputStream is = null;
      ResourceContent content = null;
      ResourceContentReader<?> reader = null;
      ResourceSerializer<?, ?> serializer = serializerService.getSerializerByType(resource.getURI().getType());
      try {
        reader = serializer.getContentReader();
        is = new FileInputStream(uploadedFile);
View Full Code Here

    if (resource == null || resource.contents().isEmpty()) {
      throw new WebApplicationException(Status.NOT_FOUND);
    }

    // Get the resource content
    ResourceContent content = resource.getContent(language);
    if (content == null) {
      throw new WebApplicationException(Status.NOT_FOUND);
    }

    ResourceURI uri = resource.getURI();
View Full Code Here

      } catch (ContentRepositoryException e) {
        logger.warn("Error adding new resource {}: {}", resourceURI, e.getMessage());
        throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
      }

      ResourceContent content = null;
      ResourceContentReader<?> reader = null;
      try {
        reader = serializer.getContentReader();
        is = new FileInputStream(uploadedFile);
        content = reader.createFromContent(is, user, language, uploadedFile.length(), fileName, mimeType);
View Full Code Here

    if (!ResourceUtils.hasChanged(request, resource, language)) {
      return Response.notModified().build();
    }

    // Load the content
    ResourceContent resourceContent = resource.getContent(language);
    if (resourceContent == null) {
      throw new WebApplicationException(Status.NOT_FOUND);
    }

    // If the content is hosted externally, send a redirect and be done with it
    if (resourceContent.getExternalLocation() != null) {
      try {
        return Response.temporaryRedirect(resourceContent.getExternalLocation().toURI()).build();
      } catch (URISyntaxException e) {
        throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
      }
    }
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.content.ResourceContent

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.