Examples of MimeType


Examples of org.ibeans.api.channel.MimeType

    {
        return new Answer()
        {
            public Object answer(InvocationOnMock invocation) throws Throwable
            {
                MimeType mime = mimeType;
                DataType ret = ((MockIBean)ibean).ibeanReturnType();
                if(ret!=null) ret.setMimeType(mime.toString());
                Object data;

                /**
                 * We need to have some special handling when dealing with a Mockito mock
                 * 1) If the return type on the ibeans is not set, use the method return type
                 * 2) the return annotation changes the return type so use the one defined on the actual Method
                 * 3) If the return type and the method return type are not assignable, then use the method return type
                 */
                if (ret == null || invocation.getMethod().isAnnotationPresent(Return.class) ||
                        !invocation.getMethod().getReturnType().isAssignableFrom(ret.getType()))
                {
                    ret = DataTypeFactory.createFromReturnType(invocation.getMethod());
                    mime = null;
                }

                data = loadData(resource, ret);
                ((MockIBean)ibean).ibeanSetMimeType(mime);
                ((MockIBean)ibean).ibeanSetMessageCallback(callback);

                Response response;
                Map<String, Object> headers = null;
                if(mime!=null)
                {
                    headers = new HashMap<String, Object>();
                    headers.put(MuleProperties.CONTENT_TYPE_PROPERTY, mime.toString());
                }
                response = plugin.createResponse(data, headers, null);
                if(callback!=null)
                {
                    callback.onMessage(response);
View Full Code Here

Examples of org.openxri.resolve.MimeType

           
            String sAccept = request.getHeader(Tags.HEADER_ACCEPT);
            // initialize the following input parameters to proxy server in addition to
            // addition flags refs, trust & sep
            MimeType resolutionMediaType = null;
            String serviceResMediaType = null;
            String serviceType = null// this always comes from http get query
           
            /*
             * We expect Accept header of format and would contain only expected variables and values
             * The general format of aceept header is: <mediatype>[;name=value]*[,<mediatype>[;named=value]*]
             * 1. If multiple mediatypes appears the proxy server shoud pick the first one.
             * 2. If mediatype is one of the application/xrd(s)+xml or text/uri-list then ResolutionMediaType=mediatype
             * and ServiceMediaType becomes null
             * 3. If mediatype doesn't match with applciation/xrd(s) or text/uri-list ResolutionMediaType=null
             * and ServiceMediaType = mediatype
             * if accept header is null then ResolutionMediaType and ServiceMediaType = null (used loose constraint)
             * 4. In any case the proxy query parameters _xrd_r and _xrd_m takes higher precendence over accept header
             */
            if (sAccept != null ){
              StringTokenizer tokenizer = new StringTokenizer(sAccept, ",");
              while (tokenizer.hasMoreTokens() ){
                String token = (String)tokenizer.nextToken();
               
                MimeType mType = MimeType.parse(token);
                if (mType == null || mType.getType() == null || mType.getType().length() == 0)
                  continue; // ignore
               
              if (mType.isValidXriResMediaType()) {
                resolutionMediaType = mType;
                serviceResMediaType = null;
                isDumbBrowser = false;
              }
              else {
                resolutionMediaType = null;
                serviceResMediaType = mType.toString();
              }
              break;
              }
            }

            QueryParams qp = parseQuery(request);


            if (qp.xrdR != null) {
              if (qp.xrdR.trim().length() == 0) {
                // parameter exists, but is empty
                resolutionMediaType = null;
              }
              else {
                MimeType mType = MimeType.parse(qp.xrdR);
              if (mType != null && mType.getType() != null && mType.getType().length() > 0) {
                // this overrides earlier value (that might be in Accept: header)
                resolutionMediaType = mType;
              }
              }
            }
View Full Code Here

Examples of org.pentaho.platform.plugin.services.importer.mimeType.MimeType

  public NameBaseMimeResolver() {
  }

  @Override
  public String resolveMimeForFileName( String fileName ) {
    MimeType mimeType = extensionToMimeMap.get( extractExtension( fileName ) );
    if ( mimeType == null ) {
      return null;
    }

    return mimeType.getName();
  }
View Full Code Here

Examples of org.projectforge.common.MimeType

   * @param filename
   * @return
   */
  public static String getContentType(final String filename)
  {
    final MimeType mimeType = MimeType.getMimeType(filename);
    if (mimeType != null) {
      return mimeType.getMimeTypeString();
    }
    log.info("Unknown file type: " + filename);
    return "";
  }
View Full Code Here

Examples of org.raml.model.MimeType

{

    @Test
    public void roundtrip()
    {
        MimeType mimeType = new MimeType();
        mimeType.setFormParameters(buildMap(Collections.singletonList(new FormParameter())));

        Action action = new Action();
        action.setBody(buildMap(mimeType));
        action.setResponses(buildMap(new Response()));
View Full Code Here

Examples of org.springframework.util.MimeType

   * @param mediaType the string to parse
   * @return the media type
   * @throws InvalidMediaTypeException if the string cannot be parsed
   */
  public static MediaType parseMediaType(String mediaType) {
    MimeType type;
    try {
      type = MimeTypeUtils.parseMimeType(mediaType);
    }
    catch (InvalidMimeTypeException ex) {
      throw new InvalidMediaTypeException(ex);
    }
    try {
      return new MediaType(type.getType(), type.getSubtype(), type.getParameters());
    }
    catch (IllegalArgumentException ex) {
      throw new InvalidMediaTypeException(mediaType, ex.getMessage());
    }
  }
View Full Code Here

Examples of org.w3c.www.mime.MimeType

      if ( strtypes == null )
    return null;
      types = new MimeType[strtypes.length];
      for (int i = 0 ; i < types.length ; i++) {
    try {
        types[i] = new MimeType(strtypes[i]);
    } catch (Exception ex) {
        types[i] = null;
    }
      }
  }
View Full Code Here

Examples of org.whattf.datatype.MimeType

                    case TYPE:
                        if (attrValue == null) {
                            break;
                        }
                        try {
                            MimeType mt = (MimeType) dl.createDatatype("mime-type");
                            mt.checkValid(attrValue);
                            attrValue = newAsciiLowerCaseStringFromString(attrValue);
                        } catch (DatatypeException e) {
                            badDatatype = true;
                            try {
                                errBadPseudoAttrDatatype(e, MimeType.class,
View Full Code Here

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

Examples of pivot.util.MIMEType

import pivot.util.MIMEType;

public class MIMETypeTest {
    public static void main(String[] args) {
        MIMEType mimeType = MIMEType.decode("foo; a=123; b=456; c=789");
        System.out.println("Base type: " + mimeType.getBaseType());
        System.out.println("a: " + mimeType.get("a"));
        System.out.println("b: " + mimeType.get("b"));
        System.out.println("c: " + mimeType.get("c"));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.