List of usage examples for org.springframework.context.support DefaultMessageSourceResolvable DefaultMessageSourceResolvable
public DefaultMessageSourceResolvable(@Nullable String[] codes, @Nullable Object[] arguments,
@Nullable String defaultMessage)
From source file:technology.tikal.customers.dao.objectify.CustomerDaoOfy.java
@Override public List<CustomerOfy> consultarTodos(CustomerFilter filtro, PaginationDataDual<Long, String> pagination) { NamePriorityFilterValues namePriority; try {/*from ww w.ja va 2s. co m*/ namePriority = Enum.valueOf(NamePriorityFilterValues.class, filtro.getIndex()); } catch (IllegalArgumentException ex) { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "IllegalIndex.CustomerDaoOfy.consultarTodos" }, new String[] { filtro.getIndex() }, "Invalid Index")); } String indexOfy = "normalized" + filtro.getIndex(); if (namePriority != NamePriorityFilterValues.Name) { indexOfy = "name." + indexOfy; } return paginatorDelegate.consultarTodosTemplate( new PaginationContext<Object>(indexOfy, filtro.getIndex(), filtro, pagination)); }
From source file:technology.tikal.customers.model.ClienteMxOfy.java
@Override public void update(Customer source) { if (source instanceof ClienteMx) { super.update(source); ClienteMx cliente = (ClienteMx) source; this.setDomicilioFiscal(AddressFactory.buildInternal(cliente.getDomicilioFiscal())); this.setRfc(cliente.getRfc()); } else {/*from w ww. j a v a 2s . c o m*/ throw new MessageSourceResolvableException( new DefaultMessageSourceResolvable(new String[] { "NotSupportedClass.ClienteMxOfy.update" }, new String[] { source.getClass().getSimpleName() }, "ClienteMx object expected")); } }
From source file:technology.tikal.accounts.controller.imp.AccountsControllerImp.java
@Override public void createAccount(final Account account) { InternalAccount cuenta = new InternalAccount(account); try {/* w w w.j a v a 2s . c o m*/ this.accountDao.consultar(cuenta.getIdUser()); throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "DuplicatedAccount.AccountsControllerImp.createAccount" }, new String[] { cuenta.getIdUser() }, "Duplicated Account")); } catch (NotFoundException e) { this.accountDao.guardar(cuenta); } }
From source file:technology.tikal.customers.model.contact.AssociateOfy.java
@Override public void update(Contact source) { super.update(source); if (source instanceof Associate) { Associate associate = (Associate) source; this.setRole(associate.getRole()); } else {/*from w w w . j av a 2 s.c o m*/ throw new MessageSourceResolvableException( new DefaultMessageSourceResolvable(new String[] { "NotSupportedClass.AssociateOfy.update" }, new String[] { source.getClass().getSimpleName() }, "Associate object expected")); } }
From source file:technology.tikal.ventas.controller.almacen.imp.EntradaDevolucionControllerImp.java
@Override public EntradaDevolucion crear(Long pedidoId, RegistroAlmacenTransient request) { Pedido pedido = pedidoController.get(pedidoId); Producto producto = productoController.cargar(request.getProducto().getCatalogoId(), request.getProducto().getId()); RegistroAlmacen referencia = null;//from w w w. ja v a 2s. c o m if (request.getReferenciaRegistro() != null) { try { referencia = salidaDevolucionController.get(pedidoId, request.getReferenciaRegistro()); } catch (NotFoundException e) { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "RefNotFound.EntradaDevolucionControllerImp.crear" }, new String[] { pedidoId + "" }, "No se encontro la referencia")); } } else { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "RefRequired.EntradaDevolucionControllerImp.crear" }, new String[] { pedidoId + "" }, "No se encontro la referencia")); } EntradaDevolucionOfy nuevo = RegistroAlmacenFactory.buildDevolucion(pedido, request, producto, EntradaDevolucionOfy.class, referencia); entradaDevolucionDao.guardar(pedido, nuevo); return nuevo; }
From source file:technology.tikal.customers.dao.objectify.ContactDaoOfy.java
@Override public List<ContactOfy> consultarTodos(CustomerOfy parent, ContactFilter filtro, PaginationDataDual<Long, String> pagination) { if (filtro.getIndex().compareTo("Role") == 0) { String indexOfy = "normalizedRole"; return contactRolePaginator.consultarTodosTemplate( new PaginationContext<CustomerOfy>(indexOfy, filtro.getIndex(), filtro, pagination, parent)); } else {/* w w w .j av a 2 s.co m*/ NamePriorityFilterValues namePriority; try { namePriority = Enum.valueOf(NamePriorityFilterValues.class, filtro.getIndex()); } catch (IllegalArgumentException ex) { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "IllegalIndex.ContactDaoOfy.consultarTodos" }, new String[] { filtro.getIndex() }, "Invalid Index")); } String indexOfy = "normalized" + filtro.getIndex(); if (namePriority != NamePriorityFilterValues.Name) { indexOfy = "name." + indexOfy; } return contactNamePaginator.consultarTodosTemplate( new PaginationContext<CustomerOfy>(indexOfy, filtro.getIndex(), filtro, pagination, parent)); } }
From source file:technology.tikal.gae.system.service.imp.SystemAccountServiceImp.java
@Override @RequestMapping(method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED)/*from w ww.j ava2 s. c o m*/ public void createSystemAccount(@Valid @RequestBody final SystemUser account, final BindingResult result, final HttpServletRequest request, final HttpServletResponse response) { if (result.hasErrors()) { throw new NotValidException(result); } if (account.getUsername() == null) { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "NotNull.systemUser.username" }, new String[] {}, "Null username")); } if (account.getPassword() == null) { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "NotNull.systemUser.password" }, new String[] {}, "Null password User")); } try { this.systemUserDao.consultar(account.getUsername()); throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "Duplicated.SystemAccountServiceImp.createSystemAccount" }, new String[] { account.getUsername() }, "Duplicated User")); } catch (NotFoundException e) { this.systemUserDao.guardar(account); response.setHeader("Location", request.getRequestURI() + "/" + account.getUsername()); } }
From source file:technology.tikal.ventas.controller.almacen.imp.SalidaDevolucionControllerImp.java
@Override public SalidaDevolucion crear(Long pedidoId, RegistroAlmacenTransient request) { Pedido pedido = pedidoController.get(pedidoId); Producto producto = productoController.cargar(request.getProducto().getCatalogoId(), request.getProducto().getId()); RegistroAlmacen referencia = null;//from w w w .j a v a 2 s.c o m if (request.getReferenciaRegistro() != null) { try { referencia = entradaController.get(pedidoId, request.getReferenciaRegistro()); } catch (NotFoundException e) { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "RefNotFound.SalidaDevolucionControllerImp.crear" }, new String[] { pedidoId + "" }, "No se encontro la referencia")); } } else { throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "RefRequired.SalidaDevolucionControllerImp.crear" }, new String[] { pedidoId + "" }, "No se encontro la referencia")); } SalidaDevolucionOfy nuevo = RegistroAlmacenFactory.buildDevolucion(pedido, request, producto, SalidaDevolucionOfy.class, referencia); salidaDevolucionDao.guardar(pedido, nuevo); return nuevo; }
From source file:org.springmodules.validation.commons.MessageUtils.java
/** * Create a MessageSourceResolvable using the string value of the parameter * as a code.//w w w . j a v a2s . co m * <p/> * <p/> * Note: this implementation uses the key of the Fields message for the * given ValidatorAction as the default message. * </p> * * @param obj Object whose string value is the code for this message. * @return MessageSourceResolvable for the given Object. */ public static MessageSourceResolvable createMessage(Object obj) { String[] codes = new String[] { String.valueOf(obj) }; String defaultMsg = codes[0]; return new DefaultMessageSourceResolvable(codes, null, defaultMsg); }
From source file:technology.tikal.customers.controller.imp.CustomersControllerImp.java
@Override public Customer createCustomerWithForcedId(Long id, Customer data) { try {/*from ww w . j a va 2 s . c o m*/ this.customerDao.consultar(id); throw new MessageSourceResolvableException(new DefaultMessageSourceResolvable( new String[] { "DuplicatedId.CustomersControllerImp.createCustomerWithForcedId" }, new String[] { id.toString() }, "Duplicated Id for new customer")); } catch (NotFoundException e) { CustomerOfy nuevo = CustomerOfyFactory.buildInternalWithForcedId(id, data); this.customerDao.guardar(nuevo); return nuevo; } }