Package org.wymiwyg.commons.mediatypes

Examples of org.wymiwyg.commons.mediatypes.MimeType


    if ((childStrings == null) || (childStrings.length == 0)) {
      throw new HandlerException(ResponseStatus.NOT_FOUND, "file "+baseName+" not found");
    }
    // TODO content negotiation
    String fileName = childStrings[0];
    MimeType mimeType = MediaTypesUtil.getDefaultInstance().getTypeForExtension(getExtension(fileName));
    if (mimeType != null) {
      response.addHeader(HeaderName.CONTENT_TYPE, mimeType.toString());
    }
    PathNode resultNode = pathNode.getSubPath(fileName);
    final InputStream dataInputStream;
    try {
      //log.info("getting stream from"+fileName+" in "+pathNode+"("+resultNode+")");
View Full Code Here


                  attachmentURLs[i]);
            } catch (MalformedURLException e) {
              throw new RuntimeException(e);
            }

            MimeType mimeType;
            if ((urlAttachmentContentTypes[i] != null)
                && (!urlAttachmentContentTypes[i].equals(""))) {
              try {
                mimeType = new MimeType(
                    urlAttachmentContentTypes[i]);
              } catch (MimeTypeParseException e) {
                throw new HandlerException("Invalid MimeType",
                    e);
              }
            } else {
              mimeType = null;
            }
            attachmentsSet.add(new Attachment(labels,
                attachmnetTargetURL, mimeType, width, height,
                attachmentMode[i].equals("inline"),
                attachmentLanguage, position, summmaryViews[i]
                    .equals("true")));
            /*
             * Resource attachmentTarget =
             * model.createResource(attachmnetTargetURL.toString());
             * ItemUtil.addAttachment(target, attachmentTarget,
             * urlAttachmentContentTypes[i], attachmentLabels[i],
             * width, height, attachmentMode[i].equals("inline"));
             */
          }
          // urlIter++;

        } else {
          if ((attachmentContent != null)
              && (attachmentContent[i] != null)
              && (attachmentContent[i].length > 0)) {
            String fileName = fileNames[i];
            MimeType mimeType;
            mimeType = fileContentTypes[i];
            try {
              attachmentsSet.add(new Attachment(model, hashStore,
                  new URL(target.getURI()), labels,
                  attachmentContent[i], fileName, mimeType,
View Full Code Here

                mimeTypeString = ((Object[]) value)[0].toString();
            } else {
                mimeTypeString = value.toString();
            }
            try {
                MimeType mimeType = new MimeType(mimeTypeString);
                if (!xmlRange.match(mimeType)) {
                    super.setHeader(headerName, value);
                    return;
                }
                String stylesheetParam = mimeType.getParameter("stylesheet");
                if ((stylesheetParam == null)
                        || (stylesheetParam.equals("none"))) {
                    super.setHeader(headerName, value);
                    return;
                }
View Full Code Here

   * @see org.wymiwyg.rwcf.Handler#handle(org.wymiwyg.wrhapi.Request,
   *           org.wymiwyg.rwcf.Response, org.wymiwyg.rwcf.HandlerChain)
   */
  public void handle(Request request, Response response, HandlerChain chain)
      throws HandlerException {
    MimeType type = getMimeType(request);
    BodyConverter converter = getBodyConvertor(type);
    if (converter != null) {
      request = new RequestWrapper(request, converter, type);
    }
    chain.doNext(request, response);
View Full Code Here

   * @param request
   * @return
   * @throws HandlerException
   */
  private MimeType getMimeType(Request request) throws HandlerException {
    MimeType type;
    String[] typeStrings = request.getHeaderValues(HeaderName.CONTENT_TYPE);
    if (typeStrings.length > 0) {
      try {
        type = new MimeType(typeStrings[0]);
      } catch (MimeTypeParseException e) {
        throw new HandlerException("Invalid MimeType: "
            + typeStrings[0]);
      }
    } else {
View Full Code Here

   */
  public MimeType getMimeType() {
    Statement contentypeStmt = variant.getProperty(DOCUMENT.contentType);
    try {
      if (contentypeStmt == null) {
        return new MimeType("uknown/unknown");
      }
      return new MimeType(contentypeStmt.getString());
    } catch (MimeTypeParseException e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

    try {
      StmtIterator targetTypeStmtIter = handlerResource
          .listProperties(RWCF.targetType);
      Collection targetContentTypeList = new ArrayList();
      while (targetTypeStmtIter.hasNext()) {
        targetContentTypeList.add(new MimeType(targetTypeStmtIter
            .nextStatement().getString()));
      }
      targetContentTypes = (MimeType[]) targetContentTypeList
          .toArray(new MimeType[targetContentTypeList.size()]);
View Full Code Here


  public static void readProperties(MimeType type, byte[] content,
      Resource resource) {
    try {
      if (!type.getBaseType().equals("audio") && !type.equals(new MimeType("application", "ogg"))) {
        return;
      }
      File tempFile = File.createTempFile("audio-upload","."+MediaTypesUtil.getDefaultInstance().getExtensionForType(type));
      System.out.print(tempFile);
      FileOutputStream fileOut = new FileOutputStream(tempFile);
View Full Code Here

      out.write(ch);
    }
    Model model = ModelFactory
    .createDefaultModel();
     
    readProperties(new MimeType(
        "application/ogg"),  out.toByteArray(), model.createResource());
  }
View Full Code Here

  public void createDocument(Resource resource, MultiPartBody body,
      String field) throws HandlerException {
    byte[] fileContent = body.getFileContent(field);
    String language = body.getParameter("language");
    MimeType mimeType = body.getFileContentType(field);
    createDocument(resource, fileContent, language, mimeType, hashStore);
  }
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.