Package com.bacoder.parser.java

Examples of com.bacoder.parser.java.JavaParser$ResourceContext


      GetResource getResource = ResourceServingUtil.decode(req);

      try
      {
         ResourceResponse resource = producer.getResource(getResource);
         ResourceContext resourceContext = resource.getResourceContext();
         byte[] itemBinary = resourceContext.getItemBinary();
         String itemString = resourceContext.getItemString();

         final String mimeType = resourceContext.getMimeType();
         if (!ParameterValidation.isNullOrEmpty(mimeType))
         {
            resp.setContentType(mimeType);
         }
View Full Code Here


      // if length is not known, use a default value
      length = (length > 0 ? length : Tools.DEFAULT_BUFFER_SIZE * 8);
      byte[] bytes = IOTools.getBytes(urlConnection.getInputStream(), length);


      ResourceContext resourceContext;
      MediaType type = MediaType.create(contentType);

      // GTNCOMMON-14
      if (isInterpretableAsText(type))
      {
         // determine the charset of the content, if any
         String charset = "UTF-8";
         if (contentType != null)
         {
            for (String part : contentType.split(";"))
            {
               if (part.startsWith("charset="))
               {
                  charset = part.substring("charset=".length());
               }
            }
         }

         String markup = new String(bytes, charset);

         resourceContext = WSRPTypeFactory.createResourceContext(contentType, markup, null);

         // process markup if needed
         SubtypeDef subtype = type.getSubtype();
         if (SubtypeDef.HTML.equals(subtype) || SubtypeDef.CSS.equals(subtype) || subtype.getName().contains("javascript") || SubtypeDef.XML.equals(subtype))
         {
            resourceContext.setRequiresRewriting(true);
         }
      }
      else
      {
         resourceContext = WSRPTypeFactory.createResourceContext(contentType, null, bytes);
         resourceContext.setRequiresRewriting(false);
      }

      return WSRPTypeFactory.createResourceResponse(resourceContext);
   }
View Full Code Here

      GetResource getResource = ResourceServingUtil.decode(req);

      try
      {
         ResourceResponse resource = producer.getResource(getResource);
         ResourceContext resourceContext = resource.getResourceContext();
         byte[] itemBinary = resourceContext.getItemBinary();
         String itemString = resourceContext.getItemString();

         final String mimeType = resourceContext.getMimeType();
         if (!ParameterValidation.isNullOrEmpty(mimeType))
         {
            resp.setContentType(mimeType);
         }
View Full Code Here

      int length = urlConnection.getContentLength();
      // if length is not known, use a default value
      length = (length > 0 ? length : Tools.DEFAULT_BUFFER_SIZE * 8);
      byte[] bytes = IOTools.getBytes(urlConnection.getInputStream(), length);

      ResourceContext resourceContext;
      // GTNCOMMON-14
      if (MIMEUtils.isInterpretableAsText(contentType))
      {
         // determine the charset of the content, defaulting to UTF-8 if there isn't one
         String charset = MIMEUtils.getCharsetFrom(contentType);
         String markup = new String(bytes, charset);
         resourceContext = WSRPTypeFactory.createResourceContext(contentType, markup, null);

         // process markup if needed
         if (MIMEUtils.needsRewriting(contentType))
         {
            resourceContext.setRequiresRewriting(true);
         }
      }
      else
      {
         resourceContext = WSRPTypeFactory.createResourceContext(contentType, null, bytes);
         resourceContext.setRequiresRewriting(false);
      }


      return WSRPTypeFactory.createResourceResponse(resourceContext);
   }
View Full Code Here

      GetResource getResource = ResourceServingUtil.decode(req);

      try
      {
         ResourceResponse resource = producer.getResource(getResource);
         ResourceContext resourceContext = resource.getResourceContext();
         byte[] itemBinary = resourceContext.getItemBinary();
         String itemString = resourceContext.getItemString();

         final String mimeType = resourceContext.getMimeType();
         if (!ParameterValidation.isNullOrEmpty(mimeType))
         {
            resp.setContentType(mimeType);
         }
View Full Code Here

      int length = urlConnection.getContentLength();
      // if length is not known, use a default value
      length = (length > 0 ? length : Tools.DEFAULT_BUFFER_SIZE * 8);
      byte[] bytes = IOTools.getBytes(urlConnection.getInputStream(), length);

      ResourceContext resourceContext;
      // GTNCOMMON-14
      if (MIMEUtils.isInterpretableAsText(contentType))
      {
         // determine the charset of the content, defaulting to UTF-8 if there isn't one
         String charset = MIMEUtils.getCharsetFrom(contentType);
         String markup = new String(bytes, charset);
         resourceContext = WSRPTypeFactory.createResourceContext(contentType, markup, null);

         // process markup if needed
         if (MIMEUtils.needsRewriting(contentType))
         {
            resourceContext.setRequiresRewriting(true);
         }
      }
      else
      {
         resourceContext = WSRPTypeFactory.createResourceContext(contentType, null, bytes);
         resourceContext.setRequiresRewriting(false);
      }


      return WSRPTypeFactory.createResourceResponse(resourceContext);
   }
View Full Code Here

      int length = urlConnection.getContentLength();
      // if length is not known, use a default value
      length = (length > 0 ? length : Tools.DEFAULT_BUFFER_SIZE * 8);
      byte[] bytes = IOTools.getBytes(urlConnection.getInputStream(), length);

      ResourceContext resourceContext;
      // GTNCOMMON-14
      if (MIMEUtils.isInterpretableAsText(contentType))
      {
         // determine the charset of the content, defaulting to UTF-8 if there isn't one
         String charset = MIMEUtils.getCharsetFrom(contentType);
         String markup = new String(bytes, charset);
         resourceContext = WSRPTypeFactory.createResourceContext(contentType, markup, null);

         // process markup if needed
         if (MIMEUtils.needsRewriting(contentType))
         {
            resourceContext.setRequiresRewriting(true);
         }
      }
      else
      {
         resourceContext = WSRPTypeFactory.createResourceContext(contentType, null, bytes);
         resourceContext.setRequiresRewriting(false);
      }


      return WSRPTypeFactory.createResourceResponse(resourceContext);
   }
View Full Code Here

TOP

Related Classes of com.bacoder.parser.java.JavaParser$ResourceContext

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.