コード例 #1
0
 @Transactional(readOnly = true)
 public SorPerson findByPersonIdAndSorIdentifier(
     final Long personId, final String sorSourceIdentifier) {
   try {
     return this.personRepository.findByPersonIdAndSorIdentifier(personId, sorSourceIdentifier);
   } catch (final Exception e) {
     logger.debug(e.getMessage(), e);
     return null;
   }
 }
コード例 #2
0
ファイル: QueryParser.java プロジェクト: rdettai/kairosdb
  private void deserializeProperties(
      String context, JsonObject jsonObject, String name, Object object)
      throws QueryException, BeanValidationException {
    Set<Map.Entry<String, JsonElement>> props = jsonObject.entrySet();
    for (Map.Entry<String, JsonElement> prop : props) {
      String property = prop.getKey();
      if (property.equals("name")) continue;

      PropertyDescriptor pd = null;
      try {
        pd = getPropertyDescriptor(object.getClass(), property);
      } catch (IntrospectionException e) {
        logger.error("Introspection error on " + object.getClass(), e);
      }

      if (pd == null) {
        String msg =
            "Property '"
                + property
                + "' was specified for object '"
                + name
                + "' but no matching setter was found on '"
                + object.getClass()
                + "'";

        throw new QueryException(msg);
      }

      Class propClass = pd.getPropertyType();

      Object propValue;
      try {
        propValue = m_gson.fromJson(prop.getValue(), propClass);
        validateObject(propValue, context + "." + property);
      } catch (ContextualJsonSyntaxException e) {
        throw new BeanValidationException(
            new SimpleConstraintViolation(e.getContext(), e.getMessage()), context);
      } catch (NumberFormatException e) {
        throw new BeanValidationException(
            new SimpleConstraintViolation(property, e.getMessage()), context);
      }

      Method method = pd.getWriteMethod();
      if (method == null) {
        String msg =
            "Property '"
                + property
                + "' was specified for object '"
                + name
                + "' but no matching setter was found on '"
                + object.getClass().getName()
                + "'";

        throw new QueryException(msg);
      }

      try {
        method.invoke(object, propValue);
      } catch (Exception e) {
        logger.error("Invocation error: ", e);
        String msg =
            "Call to "
                + object.getClass().getName()
                + ":"
                + method.getName()
                + " failed with message: "
                + e.getMessage();

        throw new QueryException(msg);
      }
    }
  }