Examples of ContentType


Examples of org.gatein.mop.api.content.ContentType

   private static String getApplicationIconURL(ContentDefinition contentDef)
   {
      Customization customization = contentDef.getCustomization();
      if (customization != null)
      {
         ContentType type = customization.getType();
         String contentId = customization.getContentId();
         if (type == Portlet.CONTENT_TYPE)
         {
            String[] chunks = contentId.split("/");
            if (chunks.length == 2)
View Full Code Here

Examples of org.glassfish.grizzly.http.util.ContentType

            if (contentLanguage != null) {
                headers.setValue(Header.ContentLanguage).setString(contentLanguage);
            }
           
            // Optimize content-type serialization depending on its state
            final ContentType contentType = response.getContentTypeHolder();
            if (contentType.isMimeTypeSet()) {
                final DataChunk contentTypeValue = headers.setValue(Header.ContentType);
                if (contentTypeValue.isNull()) {
                    contentType.serializeToDataChunk(contentTypeValue);
                }
            } else if (defaultResponseContentType != null) {
                final DataChunk contenTypeValue = headers.setValue(Header.ContentType);
                if (contenTypeValue.isNull()) {
                    final String ce = response.getCharacterEncoding();
View Full Code Here

Examples of org.jboss.portal.common.net.media.ContentType

      MediaType mediaType = null;
     
      String contentTypeString = getContentType();
      if (contentTypeString != null)
      {
         ContentType contentType = ContentType.create(contentTypeString);
         mediaType = contentType.getMediaType();
         for (Parameter parameter : contentType.getParameters())
         {
            if (!parameter.getName().trim().toLowerCase().equals("charset"))
            {
               parameters.add(parameter);
            }
         }
      }
      else
      {
         // Default to "text/html"
         mediaType = MediaType.TEXT_HTML;
      }
      parameters.add(new Parameter("charset", s));
     
      setContentType(new ContentType(mediaType, parameters).getValue());
   }
View Full Code Here

Examples of org.jwat.common.ContentType

        String digestStr = "sha1:Y4N5SWNQBIBIGQ66IFXDMLGJW6FZFV6U";
        WarcDigest digestObj = WarcDigest.parseWarcDigest(digestStr);

        String contentTypeStr = "application/http; msgtype=response";
        ContentType contentTypeObj = ContentType.parseContentType(contentTypeStr);

        String dateStr = "2012-05-17T00:14:47Z";
        Date dateObj = WarcDateParser.getDate(dateStr);

        String inetAddressStr = "172.20.10.12";
        InetAddress inetAddressObj = null;
        try {
            inetAddressObj = InetAddress.getByName(inetAddressStr);
        } catch (UnknownHostException e) {
            e.printStackTrace();
            Assert.fail("Unexpected exception!");
        }

        String uriStr = "urn:uuid:a1bc4f20-d057-44bd-a299-bdf31f4dfa53";
        Uri uriObj = Uri.create(uriStr);

        /*
         * Non warc headers.
         */

        header = getTestHeader();
        headerLine = header.addHeader("X-Header1", dateObj, dateStr);
        Assert.assertNotNull(headerLine);
        Assert.assertEquals("X-Header1", headerLine.name);
        Assert.assertEquals(dateStr, headerLine.value);
        headerLine = header.addHeader("X-Header2", dateObj, dateStr);
        Assert.assertNotNull(headerLine);
        Assert.assertEquals("X-Header2", headerLine.name);
        Assert.assertEquals(dateStr, headerLine.value);

        /*
         * Duplicate date headers.
         */

        header = getTestHeader();
        headerLine = header.addHeader("WARC-Date", dateObj, dateStr);
        Assert.assertNotNull(headerLine);
        Assert.assertEquals("WARC-Date", headerLine.name);
        Assert.assertEquals(dateStr, headerLine.value);
        errors = header.diagnostics.getErrors();
        warnings = header.diagnostics.getWarnings();
        Assert.assertEquals(0, errors.size());
        Assert.assertEquals(0, warnings.size());
        headerLine = header.addHeader("WARC-Date", dateObj, dateStr);
        Assert.assertNotNull(headerLine);
        Assert.assertEquals("WARC-Date", headerLine.name);
        Assert.assertEquals(dateStr, headerLine.value);
        errors = header.diagnostics.getErrors();
        warnings = header.diagnostics.getWarnings();
        Assert.assertEquals(1, errors.size());
        Assert.assertEquals(0, warnings.size());
        diagnosis = errors.get(0);
        Assert.assertEquals(DiagnosisType.DUPLICATE, diagnosis.type);
        Assert.assertEquals("'WARC-Date' header", diagnosis.entity);
        Assert.assertEquals(1, diagnosis.information.length);

        /*
         * Integer add header.
         */

        cases = generate_invalid_datatype_cases(integerObj, integerStr, WarcConstants.FN_WARC_SEGMENT_NUMBER, WarcConstants.FN_WARC_RECORD_ID);
        test_headeradd_object_cases(cases, WarcConstants.FDT_INTEGER);

        /*
         * Long add header.
         */

        cases = generate_invalid_datatype_cases(longObj, longStr, WarcConstants.FN_CONTENT_LENGTH, WarcConstants.FN_CONTENT_TYPE);
        test_headeradd_object_cases(cases, WarcConstants.FDT_LONG);

        /*
         * Digest add header.
         */

        cases = generate_invalid_datatype_cases(digestObj, digestStr, WarcConstants.FN_WARC_BLOCK_DIGEST, WarcConstants.FN_WARC_SEGMENT_NUMBER);
        test_headeradd_object_cases(cases, WarcConstants.FDT_DIGEST);

        /*
         * ContentType add header.
         */

        cases = generate_invalid_datatype_cases(contentTypeObj, contentTypeStr, WarcConstants.FN_CONTENT_TYPE, WarcConstants.FN_WARC_BLOCK_DIGEST);
        test_headeradd_object_cases(cases, WarcConstants.FDT_CONTENTTYPE);

        /*
         * Date add header.
         */

        cases = generate_invalid_datatype_cases(dateObj, dateStr, WarcConstants.FN_WARC_DATE, WarcConstants.FN_CONTENT_TYPE);
        test_headeradd_object_cases(cases, WarcConstants.FDT_DATE);

        /*
         * InetAddress add header.
         */

        cases = generate_invalid_datatype_cases(inetAddressObj, inetAddressStr, WarcConstants.FN_WARC_IP_ADDRESS, WarcConstants.FN_WARC_DATE);
        test_headeradd_object_cases(cases, WarcConstants.FDT_INETADDRESS);

        /*
         * URI add header.
         */

        cases = generate_invalid_datatype_cases(uriObj, "<" + uriStr + ">", WarcConstants.FN_WARC_RECORD_ID, WarcConstants.FN_WARC_IP_ADDRESS);
        test_headeradd_object_cases(cases, WarcConstants.FDT_URI);

        /*
         * Test datatype for headers.
         */

        /*
        WarcConstants.FN_WARC_TYPE
        WarcConstants.FN_WARC_TRUNCATED
        WarcConstants.FN_WARC_FILENAME
        WarcConstants.FN_WARC_PROFILE
        */

        /*
         * Integer.
         */

        String segmentNrStr = "42";
        Integer segmentNrObj = Integer.parseInt(segmentNrStr);
        cases = generate_header_datatype_cases(segmentNrObj, segmentNrStr, WarcConstants.FN_WARC_SEGMENT_NUMBER, "warcSegmentNumberStr", "warcSegmentNumber");
        test_headeradd_object_cases(cases, WarcConstants.FDT_INTEGER);

        /*
         * Long.
         */

        String contentLengthStr = "1234567890123456";
        Long contentLengthObj = Long.parseLong(contentLengthStr);
        cases = generate_header_datatype_cases(contentLengthObj, contentLengthStr, WarcConstants.FN_CONTENT_LENGTH, "contentLengthStr", "contentLength");
        test_headeradd_object_cases(cases, WarcConstants.FDT_LONG);

        String segmentTotalLengthStr = "9876543210987654";
        Long segmentTotalLengthObj = Long.parseLong(segmentTotalLengthStr);
        cases = generate_header_datatype_cases(segmentTotalLengthObj, segmentTotalLengthStr, WarcConstants.FN_WARC_SEGMENT_TOTAL_LENGTH, "warcSegmentTotalLengthStr", "warcSegmentTotalLength");
        test_headeradd_object_cases(cases, WarcConstants.FDT_LONG);

        /*
         * Digest.
         */

        String blockDigestStr = "sha1:Y4N5SWNQBIBIGQ66IFXDMLGJW6FZFV6U";
        WarcDigest blockDigestObj = WarcDigest.parseWarcDigest(blockDigestStr);
        cases = generate_header_datatype_cases(blockDigestObj, blockDigestStr, WarcConstants.FN_WARC_BLOCK_DIGEST, "warcBlockDigestStr", "warcBlockDigest");
        test_headeradd_object_cases(cases, WarcConstants.FDT_DIGEST);

        String payloadDigestStr = "sha1:BCCYP7NW6QIIOSM523Y5XHQKE5KWLMBD";
        WarcDigest payloadDigestObj = WarcDigest.parseWarcDigest(payloadDigestStr);
        cases = generate_header_datatype_cases(payloadDigestObj, payloadDigestStr, WarcConstants.FN_WARC_PAYLOAD_DIGEST, "warcPayloadDigestStr", "warcPayloadDigest");
        test_headeradd_object_cases(cases, WarcConstants.FDT_DIGEST);

        /*
         * ContentType.
         */

        contentTypeStr = "application/http; msgtype=request";
        contentTypeObj = ContentType.parseContentType(contentTypeStr);
        cases = generate_header_datatype_cases(contentTypeObj, contentTypeStr, WarcConstants.FN_CONTENT_TYPE, "contentTypeStr", "contentType");
        test_headeradd_object_cases(cases, WarcConstants.FDT_CONTENTTYPE);

        String identifiedPayloadTypeStr = "application/http; msgtype=response";
        ContentType identifiedPayloadTypeObj = ContentType.parseContentType(identifiedPayloadTypeStr);
        cases = generate_header_datatype_cases(identifiedPayloadTypeObj, identifiedPayloadTypeStr, WarcConstants.FN_WARC_IDENTIFIED_PAYLOAD_TYPE, "warcIdentifiedPayloadTypeStr", "warcIdentifiedPayloadType");
        test_headeradd_object_cases(cases, WarcConstants.FDT_CONTENTTYPE);

        /*
         * Date.
 
View Full Code Here

Examples of org.locationtech.udig.catalog.document.IDocument.ContentType

            typeViewer.setContentProvider(ArrayContentProvider.getInstance());
            typeViewer.setLabelProvider(new LabelProvider() {
                @Override
                public String getText(Object element) {
                    if (element instanceof ContentType) {
                        final ContentType type = (ContentType) element;
                        return DocUtils.toCamelCase(type.name());
                    }
                    return super.getText(element);
                }
            });
            typeViewer.setInput(IDocument.ContentType.values());
View Full Code Here

Examples of org.openjena.atlas.web.ContentType

        try {
            String graphName = null ;
            Graph graphTmp = GraphFactory.createGraphMem() ;
            Node gn = null ;
            String name = null
            ContentType ct = null ;
            Lang lang = null ;
            int tripleCount = 0 ;
           
            FileItemIterator iter = upload.getItemIterator(request);
            while (iter.hasNext()) {
                FileItemStream item = iter.next();
                String fieldName = item.getFieldName();
                InputStream stream = item.openStream();
                if (item.isFormField())
                {
                    // Graph name.
                    String value = Streams.asString(stream, "UTF-8") ;
                    if ( fieldName.equals(HttpNames.paramGraph) )
                    {
                        graphName = value ;
                        if ( graphName != null && ! graphName.equals(HttpNames.valueDefault) )
                        {
                            IRI iri = IRIResolver.parseIRI(value) ;
                            if ( iri.hasViolation(false) )
                                errorBadRequest("Bad IRI: "+graphName) ;
                            if ( iri.getScheme() == null )
                                errorBadRequest("Bad IRI: no IRI scheme name: "+graphName) ;
                            if ( iri.getScheme().equalsIgnoreCase("http") || iri.getScheme().equalsIgnoreCase("https"))
                            {
                                // Redundant??
                                if ( iri.getRawHost() == null )
                                    errorBadRequest("Bad IRI: no host name: "+graphName) ;
                                if ( iri.getRawPath() == null || iri.getRawPath().length() == 0 )
                                    errorBadRequest("Bad IRI: no path: "+graphName) ;
                                if ( iri.getRawPath().charAt(0) != '/' )
                                    errorBadRequest("Bad IRI: Path does not start '/': "+graphName) ;
                            }
                            gn = Node.createURI(graphName) ;
                        }
                    }
                    else if ( fieldName.equals(HttpNames.paramDefaultGraphURI) )
                        graphName = null ;
                    else
                        // Add file type?
                        log.info(format("[%d] Upload: Field="+fieldName+" - ignored")) ;
                } else {
                    // Process the input stream
                    name = item.getName() ;
                    if ( name == null || name.equals("") || name.equals("UNSET FILE NAME") )
                        errorBadRequest("No name for content - can't determine RDF syntax") ;
                   
                    String contentTypeHeader = item.getContentType() ;
                    ct = ContentType.parse(contentTypeHeader) ;
                   
                    lang = FusekiLib.langFromContentType(ct.getContentType()) ;
                    if ( lang == null )
                        lang = Lang.guess(name) ;
                    if ( lang == null )
                        // Desperate.
                        lang = Lang.RDFXML ;
                   
                    String base = "http://example/upload-base/" ;
                    // We read into a in-memory graph, then (if successful) update the dataset.
                    // This isolates errors.
                    Sink<Triple> sink = new SinkTriplesToGraph(graphTmp) ;
                    LangRIOT parser = RiotReader.createParserTriples(stream, lang, base, sink) ;
                    parser.getProfile().setHandler(errorHandler) ;
                    try {
                        parser.parse() ;
                    }
                    catch (RiotException ex) { errorBadRequest("Parse error: "+ex.getMessage()) ; }
                    finally { sink.close() ; }
                   
                    tripleCount = graphTmp.size() ;
                    //DatasetGraph dsgTmp = DatasetGraphFactory.create(graphTmp) ;
                }
            }   
               
            if ( graphName == null )
                graphName = "default" ;
            log.info(format("[%d] Upload: Filename: %s, Content-Type=%s, Charset=%s => (%s,%s,%d triple(s))",
                                      action.id, name,  ct.getContentType(), ct.getCharset(), graphName, lang.getName(), tripleCount)) ;

            // Delay updating until all form fields processed to get the graph name
            action.beginWrite() ;
            try {
                if ( graphName.equals(HttpNames.valueDefault) )
View Full Code Here

Examples of org.openjena.riot.ContentType

        HttpActionUpdate action = new HttpActionUpdate(id, desc, request, response, verbose_debug) ;
       
        // WebContent needs to migrate to using ContentType.
        String ctStr ;
        {
            ContentType incoming = FusekiLib.contentType(request) ;
            if ( incoming == null )
                ctStr = WebContent.contentTypeSPARQLUpdate ;
            else
                ctStr = incoming.getContentType() ;
        }
        // ----
       
        if (WebContent.contentTypeSPARQLUpdate.equals(ctStr))
        {
View Full Code Here

Examples of org.openxml4j.opc.internal.ContentType

import org.openxml4j.opc.internal.ContentType;

public class PackageDigitalSignature extends PackagePart {

  public PackageDigitalSignature() throws InvalidFormatException {
    super(null, null, new ContentType(""));
  }
View Full Code Here

Examples of org.pentaho.reporting.engine.classic.core.filter.types.ContentType

  private Element element;

  public StaticImageReportElementReadHandler()
  {
    element = new Element();
    element.setElementType(new ContentType());
    element.getStyle().setStyleProperty(ElementStyleKeys.SCALE, Boolean.TRUE);
  }
View Full Code Here

Examples of org.restlet.engine.header.ContentType

                        // create a representation from part.getInputStream()
                    }
                } else {
                    // Check if plain text
                    final MimeBodyPart mimeBodyPart = (MimeBodyPart) part;
                    final ContentType contentType = new ContentType(
                            mimeBodyPart.getContentType());
                    if (MediaType.TEXT_PLAIN.equals(contentType.getMediaType(),
                            true)) {
                        content = new InputRepresentation(mimeBodyPart
                                .getInputStream(), MediaType.TEXT_PLAIN);
                        break;
                    }

                    // TODO Special non-attachment cases here of
                    // image/gif, text/html, ...
                }
            }
        } else {
            // Add the email body
            if (message.getContentType() != null) {
                final ContentType contentType = new ContentType(message
                        .getContentType());
                if (MediaType.TEXT_PLAIN.equals(contentType.getMediaType(),
                        true)) {
                    content = new InputRepresentation(message.getInputStream(),
                            MediaType.TEXT_PLAIN);
                }
            }
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.