Package br.gov.frameworkdemoiselle

Examples of br.gov.frameworkdemoiselle.DemoiselleException


        if (field.isAnnotationPresent(ManagedProperty.class)) {
          // Obtém os métodos GET e SET para esta propriedade
          Method getterMethod = getGetterMethod(field);
          Method setterMethod = getSetterMethod(field);
          if (getterMethod == null && setterMethod == null) {
            throw new DemoiselleException(bundle.getString("management-invalid-property-no-getter-setter",
                type.getSimpleName(), field.getName()));
          } else if ((getterMethod != null && getterMethod.isAnnotationPresent(ManagedOperation.class))
              || (setterMethod != null && setterMethod.isAnnotationPresent(ManagedOperation.class))) {
            throw new DemoiselleException(bundle.getString("management-invalid-property-as-operation",
                type.getSimpleName()));
          }

          String propertyDescription = field.getAnnotation(ManagedProperty.class).description();
View Full Code Here


   *             if there is no managed context of the provided type and scope.
   */
  public static synchronized void activate(Class<? extends CustomContext> customContextClass,
      Class<? extends Annotation> scope) {
    if (!initialized) {
      throw new DemoiselleException(getBundle().getString("custom-context-manager-not-initialized"));
    }

    for (CustomContextCounter context : contexts) {
      if (context.isSame(customContextClass, scope)) {
        context.activate();
        return;
      }
    }

    throw new DemoiselleException(getBundle().getString("custom-context-not-found",
        customContextClass.getCanonicalName(), scope.getSimpleName()));
  }
View Full Code Here

   *             if there is no managed context of the provided type and scope.
   */
  public static synchronized void deactivate(Class<? extends CustomContext> customContextClass,
      Class<? extends Annotation> scope) {
    if (!initialized) {
      throw new DemoiselleException(getBundle().getString("custom-context-manager-not-initialized"));
    }

    for (CustomContextCounter context : contexts) {
      if (context.isSame(customContextClass, scope)) {
        context.deactivate();
        return;
      }
    }

    throw new DemoiselleException(getBundle().getString("custom-context-not-found",
        customContextClass.getCanonicalName(), scope.getSimpleName()));
  }
View Full Code Here

      type = Reflections.forName(canonicalName);

    } catch (ClassCastException cause) {
      // TODO Colocar a mensgaem apropriada mostrando como utilizar a anotação @Name corretamente com a injeção de
      // Logger.
      throw new DemoiselleException(null, cause);
    }

    return create(type);
  }
View Full Code Here

          try {
            logger.debug(bundle.getString("management-debug-invoking-operation", actionName, managedType
                .getType().getCanonicalName()));
            return method.getMethod().invoke(delegate, params);
          } catch (Exception e) {
            throw new DemoiselleException(bundle.getString("management-invoke-error", actionName), e);
          }
        } else {
          throw new DemoiselleException(bundle.getString("management-invoke-error", actionName));
        }
      } finally {
        deactivateContexts(managedType.getType());
      }
    } else {
      throw new DemoiselleException(bundle.getString("management-type-not-found"));
    }
  }
View Full Code Here

        try {
          Object delegate = Beans.getReference(managedType.getType() , managedType.getQualifiers());

          return getterMethod.invoke(delegate, (Object[]) null);
        } catch (Exception e) {
          throw new DemoiselleException(bundle.getString("management-invoke-error", getterMethod.getName()),
              e);
        } finally {
          deactivateContexts(managedType.getType());
        }
      } else {
        throw new DemoiselleException(bundle.getString("management-read-value-error", propertyName));
      }
    } else {
      throw new DemoiselleException(bundle.getString("management-type-not-found"));
    }
  }
View Full Code Here

              if (errorBuffer.length() > 0) {
                errorBuffer.insert(0, "\r\n");
                errorBuffer.insert(errorBuffer.length(), "\r\n");
              }

              throw new DemoiselleException(bundle.getString(
                  "management-validation-constraint-violation", managedType.getType()
                      .getCanonicalName(), propertyName, errorBuffer.toString()));
            }
          } else {
            logger.warn(bundle.getString("management-validation-validator-not-found"));
          }

          Method getterMethod = managedType.getFields().get(propertyName).getGetterMethod();
          Object oldValue;
          try {
            oldValue = getterMethod.invoke(delegate, (Object[]) null);
          } catch (Exception e) {
            oldValue = null;
          }

          method.invoke(delegate, new Object[] { newValue });

          // Manda uma notificação de mudança de atributo
          NotificationManager notificationManager = Beans.getReference(NotificationManager.class);
          Class<? extends Object> attributeType = newValue != null ? newValue.getClass() : null;

          AttributeChangeNotification notification = new AttributeChangeNotification(bundle.getString(
              "management-notification-attribute-changed", propertyName, managedType.getType()
                  .getCanonicalName()), propertyName, attributeType, oldValue, newValue);
          notificationManager.sendNotification(notification);

        } catch (DemoiselleException de) {
          throw de;
        } catch (Exception e) {
          throw new DemoiselleException(bundle.getString("management-invoke-error", method.getName()), e);
        } finally {
          deactivateContexts(managedType.getType());
        }

      } else {
        throw new DemoiselleException(bundle.getString("management-write-value-error", propertyName));
      }
    } else {
      throw new DemoiselleException(bundle.getString("management-type-not-found"));
    }

  }
View Full Code Here

   *
   * @param method
   */
  private void validateHandler(final Method method) {
    if (method.getParameterTypes().length != 1) {
      throw new DemoiselleException(getBundle().getString("must-declare-one-single-parameter",
          method.toGenericString()));
    }
  }
View Full Code Here

  public void setRollbackOnly() {
    throw getException();
  }

  private DemoiselleException getException() {
    return new DemoiselleException(getBundle().getString("transaction-not-defined",
        Transactional.class.getSimpleName()));
  }
View Full Code Here

   * @deprecated Use {@link #getCurrentUser()} instead.
   * @see br.gov.frameworkdemoiselle.security.SecurityContext#getUser()
   */
  @Override
  public User getUser() {
    throw new DemoiselleException("Utilize o método getCurrentUser() ao invés do getUser()");
  }
View Full Code Here

TOP

Related Classes of br.gov.frameworkdemoiselle.DemoiselleException

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.