Package nexj.core.runtime

Examples of nexj.core.runtime.ValidationException


      eventList.add(address);
      eventList.add(address);

      m_response.addEvent(eventList);

      ValidationException e = new ValidationException("err.validation.requiredAttributes", new Object[]{"Contact"});

      e.addException(new MetadataValidationException("err.meta.x", new Object[]{"a", "b"}));
      e.addException(new QueryTimeoutException());
      e.setClassName("Contact");
      e.setOIDHolder(contact);
      e.setOrdinal(1);
      e.addException("firstName", new ValidationException("err.validation.requiredAttribute", new Object[]{"firstName", "Contact"}));

      m_exception = e;
      m_writer = new StringWriter();
   }
View Full Code Here


      StringReader reader = new StringReader(m_writer.toString());
      Throwable t = (Throwable)m_unmarshaller.deserialize(reader);

      assertTrue(t instanceof ValidationException);

      ValidationException e = (ValidationException)t;

      assertEquals("err.validation.requiredAttributes", e.getErrorCode());
      assertEquals(1, e.getErrorArgs().length);
      assertEquals("Contact", e.getClassName());
      assertEquals("123", e.getOIDHolder().getOID().getValue(0));
      assertEquals(1, e.getOrdinal());
      assertEquals(1, e.getExceptionCount());
      assertEquals("err.persistence.queryTimeout", ((GenericException)e.getExceptionIterator().next()).getErrorCode());
      assertEquals("err.validation.requiredAttribute", ((GenericException)e.findException("firstName")).getErrorCode());
   }
View Full Code Here

      Throwable t = (Throwable) m_unmarshaller.deserialize(new StringReader(m_writer.toString()));

      assertTrue(t instanceof ValidationException);

      ValidationException e = (ValidationException) t;

      assertEquals("err.validation.requiredAttributes", e.getErrorCode());
      assertEquals(1, e.getErrorArgs().length);
      assertEquals("Contact", e.getClassName());
      assertEquals("123", e.getOIDHolder().getOID().getValue(0));
      assertEquals(1, e.getOrdinal());
      assertEquals(1, e.getExceptionCount());
      assertEquals("err.persistence.queryTimeout", ((GenericException) e.getExceptionIterator().next()).getErrorCode());
      assertEquals("err.validation.requiredAttribute", ((GenericException) e.findException("firstName")).getErrorCode());

   }
View Full Code Here

      long lSize = parseByteValue(sSize);

      if (lSize < 0)
      {
         throw new ValidationException("err.persistence.valueRange", new Object[]{sSize});
      }

      if ((lSize & 0x3fffffffL) == 0) // GB
      {
         return Long.toString(lSize >> 30) + "G";
View Full Code Here

      int nPercent = Integer.parseInt(sPercent);

      if (nPercent < 0 || nPercent > 100)
      {
         throw new ValidationException("err.persistence.valueRange", new Object[]{sPercent});
      }

      return Integer.toString(nPercent);
   }
View Full Code Here

                  case 1:
                     int nValue = ((Number)toBind(column, column.getValueType().convert(value))).intValue();

                     if (nValue < 0 || nValue > 255)
                     {
                        throw new ValidationException("err.validation.numberRange",
                           new Object[]
                           {
                              new StringId(mapping.getAttribute().getCaption()),
                              new StringId(mapping.getAttribute().getMetaclass().getCaption()),
                              Primitive.ZERO_INTEGER,
                              Primitive.createInteger(255)
                           });
                     }

                     break;

                  case 2:
                     nValue = ((Number)toBind(column, column.getValueType().convert(value))).intValue();

                     if (nValue < Short.MIN_VALUE || nValue > Short.MAX_VALUE)
                     {
                        throw new ValidationException("err.validation.numberRange",
                           new Object[]
                           {
                              new StringId(mapping.getAttribute().getCaption()),
                              new StringId(mapping.getAttribute().getMetaclass().getCaption()),
                              Primitive.createInteger(Short.MIN_VALUE),
                              Primitive.createInteger(Short.MAX_VALUE)
                           });
                     }

                     break;
               }

               break;

            case Primitive.DECIMAL_ORDINAL:
               nPrecision = column.getPrecision(getMaxDecimalPrecision());

               int nScale = column.getScale(getMaxDecimalPrecision());
               BigDecimal decMax = BigDecimal.TEN.pow(nPrecision - nScale);

               if (((BigDecimal)toBind(column, column.getValueType().convert(value))).abs().setScale(nScale,
                  RoundingMode.HALF_UP).compareTo(decMax) >= 0)
               {
                  if (nScale > 0)
                  {
                     decMax = decMax.subtract(BigDecimal.ONE.divide(BigDecimal.TEN.pow(nScale)));
                  }

                  throw new ValidationException("err.validation.numberRange",
                     new Object[]
                     {
                        new StringId(mapping.getAttribute().getCaption()),
                        new StringId(mapping.getAttribute().getMetaclass().getCaption()),
                        decMax.negate(),
                        decMax
                     });
               }

               break;

            case Primitive.TIMESTAMP_ORDINAL:
               long lTime = ((Timestamp)toBind(column, column.getValueType().convert(value))).getTime();

               if (lTime < getMinTime() || lTime > getMaxTime())
               {
                  throw new ValidationException("err.validation.dateRange",
                     new Object[]
                     {
                        new StringId(mapping.getAttribute().getCaption()),
                        new StringId(mapping.getAttribute().getMetaclass().getCaption()),
                        new Timestamp(getMinTime()),
View Full Code Here

      eventList.add(address);
      eventList.add(address);

      m_response.addEvent(eventList);
     
      ValidationException e = new ValidationException("err.validation.requiredAttributes",
                                                      new Object[]{"Contact"});

      e.addException(new MetadataValidationException("err.meta.x", new Object[]{"a", "b"}));
      e.addException(new QueryTimeoutException());
      e.setClassName("Contact");
      e.setOIDHolder(contact);
      e.setOrdinal(1);
      e.addException("firstName",
                     new ValidationException("err.validation.requiredAttribute",
                                             new Object[]{"firstName", "Contact"}));

      m_exception = e;

      m_soapFault = new SOAPFault(m_exception);
View Full Code Here

      StringReader reader = new StringReader(m_writer.toString());
      Throwable t = (Throwable)m_unmarshaller.deserialize(reader);
     
      assertTrue(t instanceof ValidationException);
     
      ValidationException e = (ValidationException)t;

      assertEquals("err.validation.requiredAttributes", e.getErrorCode());
      assertEquals(1, e.getErrorArgs().length);
      assertEquals("Contact", e.getClassName());
      assertEquals("123", e.getOIDHolder().getOID().getValue(0));
      assertEquals(1, e.getOrdinal());
      assertEquals(1, e.getExceptionCount());
      assertEquals("err.persistence.queryTimeout",
                   ((GenericException)e.getExceptionIterator().next()).getErrorCode());
      assertEquals("err.validation.requiredAttribute",
                   ((GenericException)e.findException("firstName")).getErrorCode());
   }
View Full Code Here

            assertSame(e.getOIDHolder(), instance);
            assertEquals(1, e.getAttributeCount());
            assertEquals(m_sName, e.getAttributeIterator().next());

            ValidationException x = (ValidationException)e.findException(m_sName);

            assertNotNull(x);
            assertEquals(m_sErrCode, x.getErrorCode());
            assertSame(x.getOIDHolder(), instance);

            if (getLogger().isDebugEnabled())
            {
               getLogger().debug(x.getMessage());
            }
         }
      }

      RangeInfo[] rangeInfoArray = new RangeInfo[]
View Full Code Here

            assertSame(e.getOIDHolder(), instance);
            assertEquals(1, e.getAttributeCount());
            assertEquals(m_sName, e.getAttributeIterator().next());

            ValidationException x = (ValidationException)e.findException(m_sName);

            assertNotNull(x);
            assertEquals(m_sErrCode, x.getErrorCode());
            assertSame(x.getOIDHolder(), instance);

            if (getLogger().isDebugEnabled())
            {
               getLogger().debug(x.getMessage());
            }
         }
View Full Code Here

TOP

Related Classes of nexj.core.runtime.ValidationException

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.