Package com.linkedin.restli.internal.server

Examples of com.linkedin.restli.internal.server.RestLiInternalException


  public VelocityTemplatingEngine()
  {
    final URL templateDirUrl = getClass().getClassLoader().getResource(VELOCITY_TEMPLATE_DIR);
    if (templateDirUrl == null)
    {
      throw new RestLiInternalException("Unable to find the Velocity template resources");
    }

    StringBuilder configName;
    if ("jar".equals(templateDirUrl.getProtocol()))
    {
      _velocity = new VelocityEngine();

      // config Velocity to use the jar resource loader
      // more detail in Velocity user manual

      _velocity.setProperty(VelocityEngine.RESOURCE_LOADER, "jar");

      configName = new StringBuilder("jar.").append(VelocityEngine.RESOURCE_LOADER).append(".class");
      _velocity.setProperty(configName.toString(), JarResourceLoader.class.getName());

      configName = new StringBuilder("jar.").append(VelocityEngine.RESOURCE_LOADER).append(".path");

      // fix for Velocity 1.5: jar URL needs to be ended with "!/"
      final String normalizedUrl = templateDirUrl.toString().substring(0, templateDirUrl.toString().length() - VELOCITY_TEMPLATE_DIR.length());
      _velocity.setProperty(configName.toString(), normalizedUrl);
    }
    else if ("file".equals(templateDirUrl.getProtocol()))
    {
      _velocity = new VelocityEngine();

      final String resourceDirPath = new File(templateDirUrl.getPath()).getParent();
      configName = new StringBuilder("file.").append(VelocityEngine.RESOURCE_LOADER).append(".path");
      _velocity.setProperty(configName.toString(), resourceDirPath);
    }
    else
    {
      throw new IllegalArgumentException("Unsupported template path scheme");
    }

    _velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, Log4JLogChute.class.getName());
    _velocity.setProperty(Log4JLogChute.RUNTIME_LOG_LOG4J_LOGGER, getClass().getName());

    try
    {
      _velocity.init();
    }
    catch (Exception e)
    {
      throw new RestLiInternalException(e);
    }
  }
View Full Code Here


    {
      _velocity.mergeTemplate(actualTemplateName, VelocityEngine.ENCODING_DEFAULT, context, outWriter);
    }
    catch (Exception e)
    {
      throw new RestLiInternalException(e);
    }

    try
    {
      outWriter.flush();
View Full Code Here

          final ResourceSchema resourceSchema = codec.readResourceSchema(is);
          resourceSchemaMap.put(resourceSchema.getName(), resourceSchema);
        }
        catch (IOException e)
        {
          throw new RestLiInternalException(String.format("Error loading restspec IDL file '%s'", idlFile.getName()), e);
        }
      }
    }

    return new ResourceSchemaCollection(resourceSchemaMap);
View Full Code Here

      _codec.writeMap(outputMap, out);
    }
    catch (IOException e)
    {
      throw new RestLiInternalException(e);
    }
  }
View Full Code Here

      renderResource(resourceSchema, outputMap);
      _codec.writeMap(outputMap, out);
    }
    catch (IOException e)
    {
      throw new RestLiInternalException(e);
    }
  }
View Full Code Here

      _codec.writeMap(outputMap, out);
    }
    catch (IOException e)
    {
      throw new RestLiInternalException(e);
    }
  }
View Full Code Here

      renderDataModel(schema, outputMap);
      _codec.writeMap(outputMap, out);
    }
    catch (IOException e)
    {
      throw new RestLiInternalException(e);
    }
  }
View Full Code Here

            responseEntity = new String(_codec.mapToBytes(entityMap));
          }
        }
        catch (IOException e)
        {
          throw new RestLiInternalException(e);
        }
      }

      final ResourceMethodDocView docView = new ResourceMethodDocView(methodSchema,
                                                                      capture,
View Full Code Here

    {
      pageModel.put("example", new String(_codec.mapToBytes(example)));
    }
    catch (IOException e)
    {
      throw new RestLiInternalException(e);
    }
    addRelated(schema, pageModel);

    _templatingEngine.render("dataModel.vm", pageModel, out);
  }
View Full Code Here

        name = URLDecoder.decode(nameValuePair[0], RestConstants.DEFAULT_CHARSET_NAME);
      }
      catch (UnsupportedEncodingException e)
      {
        //should not happen, since we are using "UTF-8" as the encoding
        throw new RestLiInternalException(e);
      }
      // Key is not found in the set defined for the resource
      Key currentKey = getKeyWithName(keys, name);
      if (currentKey == null)
      {
        errorMessageBuilder.append("Unknown key part named '");
        errorMessageBuilder.append(name);
        errorMessageBuilder.append("'");
        return null;
      }

      String decodedStringValue;
      try
      {
        decodedStringValue =
                URLDecoder.decode(nameValuePair[1], RestConstants.DEFAULT_CHARSET_NAME);
      }
      catch (UnsupportedEncodingException e)
      {
        //should not happen, since we are using "UTF-8" as the encoding
        throw new RestLiInternalException(e);
      }

      compoundKey.append(name, convertSimpleValue(decodedStringValue, currentKey.getDataSchema(), currentKey.getType()));
    }
    return compoundKey;
View Full Code Here

TOP

Related Classes of com.linkedin.restli.internal.server.RestLiInternalException

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.