Package com.kurento.kmf.repository

Examples of com.kurento.kmf.repository.RepositoryItemAttributes


    this.setMetadata(new HashMap<String, String>());
  }

  private static RepositoryItemAttributes loadAttributes(GridFSFile file) {

    RepositoryItemAttributes attributes = new RepositoryItemAttributes();

    attributes.setContentLength(file.getLength());
    attributes.setLastModified(file.getUploadDate().getTime());
    attributes.setMimeType(file.getContentType());

    return attributes;
  }
View Full Code Here


    }

    elem.fireStartedEventIfFirstTime();

    RepositoryItem repositoryItem = elem.getRepositoryItem();
    RepositoryItemAttributes attributes = repositoryItem.getAttributes();

    if (debug > 0) {
      if (serveContent) {
        log("Serving resource with sessionId '"
            + sessionId
            + "' headers and data. This resource corresponds to repository item '"
            + repositoryItem.getId() + "'");
      } else {
        log("Serving resource with sessionId '"
            + sessionId
            + "' headers only. This resource corresponds to repository item '"
            + repositoryItem.getId() + "'");
      }
    }

    boolean malformedRequest = response.getStatus() >= SC_BAD_REQUEST;

    if (!malformedRequest && !checkIfHeaders(request, response, attributes)) {
      return;
    }

    String contentType = getContentType(elem, attributes);

    List<Range> ranges = null;

    if (!malformedRequest) {

      response.setHeader("Accept-Ranges", "bytes");
      response.setHeader("ETag", attributes.getETag());
      response.setHeader("Last-Modified",
          attributes.getLastModifiedHttp());

      ranges = parseRange(request, response, attributes);
    }

    long contentLength = attributes.getContentLength();

    // Special case for zero length files, which would cause a
    // (silent) ISE when setting the output buffer size
    if (contentLength == 0L) {
      serveContent = false;
View Full Code Here

    return file.exists() && file.length() > 0 ? State.STORED : State.NEW;
  }

  private static RepositoryItemAttributes loadAttributes(File file) {

    RepositoryItemAttributes attributes = new RepositoryItemAttributes();
    attributes.setContentLength(file.length());
    attributes.setLastModified(file.lastModified());

    String mimeType = null;
    try (InputStream is = new BufferedInputStream(new FileInputStream(file))) {
      mimeType = URLConnection.guessContentTypeFromStream(is);
    } catch (Exception e) {
      log.warn("Exception produced during load of attributes", e);
    }

    attributes.setMimeType(mimeType);

    return attributes;
  }
View Full Code Here

TOP

Related Classes of com.kurento.kmf.repository.RepositoryItemAttributes

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.