Examples of ValidationException


Examples of org.apache.slide.projector.descriptor.ValidationException

          if ( controlActionUri == NullValue.NULL ) controlActionUri = actionUri;
           controlParameters.put(Control.ACTION, controlActionUri);
          try {
            ProcessorManager.prepareValues(control.getParameterDescriptors(), controlParameters, context);
          } catch ( ValidationException exception ) {
            throw new ValidationException(new ErrorMessage("controlComposer/controlParameterInvalid", new Object[] { controlUri }), exception);
          }
            Value controlContainerUri = (Value)controlParameters.get(CONTROL_CONTAINER);
            ParameterDescriptor parameterDescriptor = Control.getParameterDescriptor(controlParameters, context);
            String parameterName = parameterDescriptor.getName();
            involvedParameters.add(new StringValue(parameterName));
            ParameterMessage description = (ParameterMessage)parameterDescriptor.getDescription();
            boolean required = parameterDescriptor.isRequired();
            String controlState = Control.OPTIONAL_CONTROL;
            if ( required ) {
              controlState = Control.REQUIRED_CONTROL;
            }
            Object controlValue = null;
            boolean validate = false;
            if ( mapResource != null ) {
              controlValue = mapResource.getMap().get(parameterName);
              validate = false;
              BooleanValue validateResource = ((BooleanValue)mapResource.getMap().get(VALIDATE));
              if ( validateResource != null ) validate = validateResource.booleanValue();
            }
            if ( validate ) {
              try {
                controlValue = ProcessorManager.prepareValue(parameterDescriptor, controlValue, context);
              } catch ( ValidationException exception ) {
                controlValue = StringValueDescriptor.ANY.valueOf(controlValue, context).toString();
                context.addInformation(new Information(Information.ERROR, exception.getErrorMessage(), new String[] { parameterName }));
              }
              controlParameters.put(Control.VALUE, controlValue);
              if ( hasErrors(informations, parameterName) ) {
                if ( required ) {
                  controlState = Control.REQUIRED_INVALID_CONTROL;
                } else {
                  controlState = Control.OPTIONAL_INVALID_CONTROL;
                }
                explodeInformations(controlParameters, informations, parameterName, locale);
              } else {
                if ( required ) {
                  controlState = Control.REQUIRED_VALID_CONTROL;
                } else {
                  controlState = Control.OPTIONAL_VALID_CONTROL;
                }
              }
            }
            controlParameters.put(Control.STATE, controlState);
            controlParameters.put(Control.VALUE, controlValue);
            Result controlResult = control.process(controlParameters, context);
            if ( controlContainerUri != NullValue.NULL ) {
              Processor controlContainer = ProcessorManager.getInstance().getProcessor((URI)controlContainerUri);
              Map controlContainerParameters = new HashMap();
              controlContainerParameters.putAll(parameter);
              if ( hasErrors(informations, parameterName) ) {
                explodeInformations(controlContainerParameters, informations, parameterName, locale);
              }
              controlContainerParameters.put(Control.STATE, controlState);
              controlContainerParameters.put(CONTROL, controlResult.getResultEntries().get(OUTPUT));
              controlContainerParameters.put(TITLE, description.getTitle(locale, parameterName ));
              try {
                controlContainerParameters.put(TEXT, description.getText(locale));
                controlContainerParameters.put(PROMPT, description.getPrompt(locale));
              } catch ( MessageNotFoundException exception ) {
                controlContainerParameters.put(TEXT, NO_PARAMETER_MESSAGE_AVAILABLE.getText(locale, " "));
                controlContainerParameters.put(PROMPT, NO_PARAMETER_MESSAGE_AVAILABLE.getPrompt(locale, " "));
              }
              try {
                ProcessorManager.prepareValues(controlContainer.getParameterDescriptors(), controlContainerParameters, context);
              } catch ( ValidationException exception ) {
                throw new ValidationException(new ErrorMessage("controlComposer/controlContainerParameterInvalid", new Object[] { controlContainerUri }), exception);
              }
              Result controlContainerResult = controlContainer.process(controlContainerParameters, context);
              generatedControls.add(new MapValue(controlName, (Value)controlContainerResult.getResultEntries().get(OUTPUT)));
            } else {
              generatedControls.add(new MapValue(controlName, (Value)controlResult.getResultEntries().get(OUTPUT)));
            }
            if ( controlState == Control.OPTIONAL_INVALID_CONTROL || controlState == Control.REQUIRED_INVALID_CONTROL  ) {
              state = INVALID_STATE;
            } else if ( state == DEFAULT_STATE && ( controlState == Control.OPTIONAL_VALID_CONTROL || controlState == Control.REQUIRED_VALID_CONTROL ) ) {
              state = VALID_STATE;
            }
        }
        Result composerResult = new Result(state, GENERATED_CONTROLS, new ArrayValue((Value [])generatedControls.toArray(new Value[generatedControls.size()])));
    List generatedTriggers = new ArrayList();
    for (int i = 0; i < triggerDescriptions.length; i++ ) {
          Map triggerParameters = ((MapValue)triggerDescriptions[i]).getMap();
          String triggerName = triggerParameters.get(TRIGGER_NAME).toString();
          Value involvedTriggerParameters = (Value)triggerParameters.get(Trigger.INVOLVED_PARAMETERS);
          if ( involvedTriggerParameters == NullValue.NULL ) {
            involvedTriggerParameters = new ArrayValue((StringValue[])involvedParameters.toArray(new StringValue[involvedParameters.size()]));
          }
          triggerParameters.put(Trigger.INVOLVED_PARAMETERS, involvedTriggerParameters);
          URI triggerUri = (URI)triggerParameters.get(TRIGGER);
          Trigger trigger = (Trigger)ProcessorManager.getInstance().getProcessor(triggerUri);
          Value triggerActionUri = (Value)triggerParameters.get(Trigger.ACTION);
          if ( triggerActionUri == NullValue.NULL ) triggerActionUri = actionUri;
           triggerParameters.put(Trigger.ACTION, triggerActionUri);
          try {
            ProcessorManager.prepareValues(trigger.getParameterDescriptors(), triggerParameters, context);
          } catch ( ValidationException exception ) {
            throw new ValidationException(new ErrorMessage("controlComposer/triggerParameterInvalid", new Object[] { triggerUri }), exception);
          }
            Value triggerContainerUri = (Value)triggerParameters.get(TRIGGER_CONTAINER);
            Result triggerResult = trigger.process(triggerParameters, context);
            if ( triggerContainerUri != NullValue.NULL ) {
              Processor triggerContainer = ProcessorManager.getInstance().getProcessor((URI)triggerContainerUri);
              Map triggerContainerParameters = new HashMap();
              triggerContainerParameters.putAll(parameter);
              triggerContainerParameters.put(TRIGGER, triggerResult.getResultEntries().get(OUTPUT));
              try {
                ProcessorManager.prepareValues(triggerContainer.getParameterDescriptors(), triggerContainerParameters, context);
              } catch ( ValidationException exception ) {
                throw new ValidationException(new ErrorMessage("controlComposer/triggerContainerParameterInvalid", new Object[] { triggerContainerUri }), exception);
              }
              Result triggerContainerResult = triggerContainer.process(triggerContainerParameters, context);
              generatedTriggers.add(new MapValue(triggerName, (Value)triggerContainerResult.getResultEntries().get(OUTPUT)));
            } else {
              generatedTriggers.add(new MapValue(triggerName, (Value)triggerResult.getResultEntries().get(OUTPUT)));
View Full Code Here

Examples of org.apache.tapestry.ValidationException

        Upload component = new Upload(null, validate, decoder, tracker);

        expect(decoder.getFileUpload("test")).andReturn(uploadedFile);
        expect(uploadedFile.getFileName()).andReturn("test").atLeastOnce();
        validate.validate(uploadedFile);
        expectLastCall().andThrow(new ValidationException("an error"));
        tracker.recordError(component, "an error");
        replay();

        component.processSubmission(formSupport, "test");
View Full Code Here

Examples of org.apache.tapestry5.ValidationException

    }

    public void validate(Field field, Void constraintValue, MessageFormatter formatter, String value)
            throws ValidationException
    {
        if (!PATTERN.matcher(value).matches()) throw new ValidationException(buildMessage(formatter, field));
    }
View Full Code Here

Examples of org.apache.tuscany.sca.monitor.ValidationException

        ContributionMetadata metaData;
        Monitor monitor = deployer.createMonitor();
        try {
            metaData = deployer.loadXMLDocument(IOHelper.getLocationAsURL(metaDataURL), monitor);
        } catch (Exception e) {
            throw new ValidationException(e);
        }
        monitor.analyzeProblems();
        contribution.getDeployables().addAll(metaData.getDeployables());
        contribution.getImports().addAll(metaData.getImports());
        contribution.getExports().addAll(metaData.getExports());
View Full Code Here

Examples of org.broadleafcommerce.openadmin.server.service.ValidationException

                            sb.append(" / ");
                        }
                    }
                }
               
                throw new ValidationException(invalid, "The entity has failed validation - " + sb.toString());
            }
            else {
                fieldManager.persistMiddleEntities();
            }
        } catch (IllegalAccessException e) {
View Full Code Here

Examples of org.codehaus.enunciate.contract.validation.ValidationException

    QName refQName = null;
    if (refType.isInstanceOf(JAXBElement.class.getName())) {
      String localName = xmlElementRef != null && !"##default".equals(xmlElementRef.name()) ? xmlElementRef.name() : null;
      String namespace = xmlElementRef != null ? xmlElementRef.namespace() : "";
      if (localName == null) {
        throw new ValidationException(getPosition(), "Member " + getName() + " of " + getTypeDefinition().getQualifiedName() + ": @XmlElementRef annotates a type JAXBElement without specifying the name of the JAXB element.");
      }
      refQName = new QName(namespace, localName);
    }
    else if (declaration instanceof ClassDeclaration && declaration.getAnnotation(XmlRootElement.class) != null) {
      ClassDeclaration classDeclaration = (ClassDeclaration) declaration;
      RootElementDeclaration refElement = new RootElementDeclaration(classDeclaration, ((EnunciateFreemarkerModel) FreemarkerModel.get()).findTypeDefinition(classDeclaration));
      refQName = new QName(refElement.getNamespace(), refElement.getName());
    }

    if (refQName == null) {
      throw new ValidationException(getPosition(), "Member " + getSimpleName() + " of " + getTypeDefinition().getQualifiedName() + ": " + elementDeclaration + " is neither JAXBElement nor a root element declaration.");
    }

    return refQName;
  }
View Full Code Here

Examples of org.eclipse.persistence.exceptions.ValidationException

                         } else {
                            PrivilegedAccessHelper.getDeclaredField(clazz, fieldName, false).set(clazz, attribute);
                        
                    }
                    catch (Exception e) {
                       ValidationException v = ValidationException.invalidFieldForClass(fieldName, clazz);
                       v.setInternalException(e);
                       throw v;
                    }
                }
            } catch (ConversionException exception){
            }
View Full Code Here

Examples of org.eclipse.wst.validation.internal.core.ValidationException

    }
    catch (CoreException e) {
      if (e.getCause() instanceof ValidationException) {
        throw (ValidationException) e.getCause();
      }
      throw new ValidationException(new LocalizedMessage(IMessage.ERROR_AND_WARNING, e.getMessage()), e);
    }
    return Status.OK_STATUS;
  }
View Full Code Here

Examples of org.eurekastreams.commons.exceptions.ValidationException

        context.checking(new Expectations()
        {
            {
                oneOf(postVerbValMock).validate(with(any(ActivityDTO.class)));
                will(throwException(new ValidationException()));
            }
        });

        sut.validate(currentActionContext);
        context.assertIsSatisfied();
View Full Code Here

Examples of org.exolab.castor.xml.ValidationException

        // -- check name
        if (_parent != null && _parent.getStructureType() != Structure.SCHEMA) {
            if (getName() != null) {
                String err = "Only top-level complexTypes can be named.";
                err += getName() + "is not a valid complexType.";
                throw new ValidationException(err);
            }
        }
        // -- check attributes
        _attributes.validate();

        // -- check content model
        Enumeration enumeration = _contentModel.enumerate();
        while (enumeration.hasMoreElements()) {
            ((Structure) enumeration.nextElement()).validate();
        }

        // -- make sure baseType is accessible
        XMLType type = getBaseType();
        if ((type == null) && (_baseType != null)) {
            String error = "The base type '" + _baseType + "' was not found.";
            throw new ValidationException(error);
        }
        if (type != null) {
            if (type.getStructureType() == Structure.SIMPLE_TYPE) {
                if (_restricted) {
                    String name = getName();
                    if (name == null) {
                        name = "anonymous-complexType-for-element: ";
                        if (_parent != null) {
                            // -- parent should be an element if name is null,
                            // but
                            // -- we'll check the type to be on the safe side
                            if (_parent.getStructureType() == Structure.ELEMENT) {
                                name += ((ElementDecl) _parent).getName();
                            } else {
                                name += _parent.toString();
                            }
                        }
                    }
                    String err = "complexType: " + name;
                    err += "; A complex type cannot be a restriction"
                            + " of a simpleType:";
                    err += type.getName();
                    throw new ValidationException(err);
                }
            } else if (type.getStructureType() == Structure.COMPLEX_TYPE) {

                if (!_complexContent) {
                    // we are now sure that the base is a ComplexType
                    // but is the base of this complexType a simpleType? (see
                    // 4.3.3->simpleContent->content type)
                    if (((ComplexType) type).getContentType().getType() != ContentType.SIMPLE) {
                        String name = getName();
                        if (name == null) {
                            name = "anonymous-complexType-for-element: ";
                            if (_parent != null) {
                                // -- parent should be an element if name is
                                // null, but
                                // -- we'll check the type to be on the safe
                                // side
                                if (_parent.getStructureType() == Structure.ELEMENT) {
                                    name += ((ElementDecl) _parent).getName();
                                } else {
                                    name += _parent.toString();
                                }
                            }
                        }
                        String err = "complexType: " + name;
                        err += "; When a complexType is a restriction of simpleContent the base type"
                                + " must be a complexType whose base is also simpleContent.";
                        throw new ValidationException(err);
                    }
                }
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.