Package org.wymiwyg.commons.mediatypes

Examples of org.wymiwyg.commons.mediatypes.MimeType


  }
 
  public void init(HandlerConfig config) {
    Resource handlerResource = config.getResource();
    String sourceTypeString = handlerResource.getProperty(RWCF.sourceType).getString();
    MimeType sourceType;
    try {
      sourceType = new MimeType(sourceTypeString);
    } catch (MimeTypeParseException ex) {
      throw new RuntimeException(ex);
    }
    if ("true".equals(sourceType.getParameter("localized"))) {
      localized = true;
    }
    log.info("initializing ResourceModeler");
    StmtIterator targetTypes = handlerResource
        .listProperties(RWCF.targetType);
    while (targetTypes.hasNext()) {
      String current = targetTypes.nextStatement().getString();
      try {
        targetTypeSet.add(new MimeType(current));
      } catch (MimeTypeParseException e) {
        log.error("Invalid MimeType as targetType: " + current);
      }
    }
    //model = handlerResource.getModel();
View Full Code Here


                if (currentLanguages.contains(extension)
                    || systemLanguages.contains(extension)) {
                  languages.add(0, extension);
                  continue;
                }
                MimeType mimeType = mediaTypesUtil
                    .getTypeForExtension(extension);
                if (mimeType != null) {
                  mimeTypes.add(0, mimeType);
                } else {
                  baseName += '.'+extension;
View Full Code Here

   */
  public void handle(Request request, Response response, HandlerChain chain)
      throws HandlerException {
    if (request.getMethod().equals(Method.POST)) {
      //check if content-type acceptable
      MimeType mimeType;
      try {
        mimeType = new MimeType(request
            .getHeaderValues(HeaderName.CONTENT_TYPE)[0]);
        for (int i = 0; i < deSerializers.length; i++) {
          if (deSerializers[i].supports(mimeType)) {
            request = new RequestWrapper(request, deSerializers[i]);
          }
View Full Code Here

  }
 
  public MimeType[] getSupportedTypes() {
    try {
      MimeType[] supportedTypes = new MimeType[2];
      supportedTypes[0] = new MimeType("application/rdf+xml");
      supportedTypes[1] = new MimeType("application/xml"); //annotea!
      return supportedTypes;
    } catch (MimeTypeParseException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

    } catch (MalformedURLException ex) {
      throw new RuntimeException(ex);
    }
    String language = null;
    try {
      UploadHandler.createDocument(webDocument, fileContent, language, new MimeType(fileContentType), hashStore);
    } catch (MimeTypeParseException e) {
      throw new HandlerException(e);
    }
    return webDocument;
  }
View Full Code Here

    /* (non-Javadoc)
     * @see javax.activation.DataSource#getContentType()
     */
    public String getContentType() {
      String plainContentTypeString = variant.getProperty(DOCUMENT.contentType).getString();
        MimeType plainContentType;
    try {
      plainContentType = new MimeType(plainContentTypeString);
    } catch (MimeTypeParseException e) {
      throw new RuntimeException(e);
    }
    return plainContentType+"; name=\""+label+"."+MediaTypesUtil.getDefaultInstance().getExtensionForType(plainContentType)+"\"";
    }
View Full Code Here

      }
    });
    HttpResource[] result = new HttpResource[matching.length];
    for (int i = 0; i < result.length; i++) {
      String extension = getExtension(matching[i]);
      MimeType mimeType = mediaTypesUtil.getTypeForExtension(extension);
      if (mimeType == null) {
        logger.warn("Mimetype for "+matching[i]+" could not be determined, using application/octet-stream");
        try {
          mimeType = new MimeType("application","octet-stream");
        } catch (MimeTypeParseException e) {
          throw new RuntimeException(e);
        }
      }
      result[i] = new PathNodeHttpResource(directory, matching[i],
View Full Code Here

    }
    String[] contentTypes = request.getHeaderValues(HeaderName.CONTENT_TYPE);
    if (contentTypes.length == 0) {
      removeDocument(resource);
    } else {
      MimeType type;
      try {
        type = new MimeType(contentTypes[0]);
      } catch (MimeTypeParseException e) {
        throw new RuntimeException(e);
      }
      String[] languages = request.getHeaderValues(HeaderName.CONTENT_LANGUAGE);
      String language;
View Full Code Here

        log.warn("found property of "+document+" without contentType, removing");
        variantsStmts.remove();
        variant.removeProperties();
        continue;
      }
      MimeType contentType;
      try {
        contentType = new MimeType(contentTypeString);
      } catch (MimeTypeParseException e) {
        throw new RuntimeException(e);
      }
      String language;
      Statement languageStmt = variant.getProperty(DC.language);
View Full Code Here

  private int compare(HttpResource r1, HttpResource r2) {
    if (r1.equals(r2)) {
      return 0;
    }
    MimeType m1 = r1.getMimeType();
    MimeType m2 = r2.getMimeType();
    float q1, q2;
    if (!m1.equals(m2)) {
      q1 = getAcceptQ(m1);
      q2 = getAcceptQ(m2);
    } else {
View Full Code Here

TOP

Related Classes of org.wymiwyg.commons.mediatypes.MimeType

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.